Asterisk 13 - Cannot make outbound call through trunk

Hello! I had asterisk 11.6-cert2 and it works fine. Now I’ve made second server with Asterisk 13.4 and trying to configure it like old one. Everything ok, BUT I cannot make outbound call through trunk.

There is debug from working asterisk:
<— SIP read from UDP:10.30.1.143:5060 —>
INVITE sip:7916*******@10.30.1.141;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK2140019459326311564
From: 9995 sip:9995@10.30.1.141;tag=42719609
To: “7916*******” sip:7916*******@10.30.1.141;user=phone
Call-ID: 8383154237863-88711949727093@10.30.1.143
CSeq: 1 INVITE
Contact: sip:9995@10.30.1.143:5060
Max-Forwards: 70
Supported: replaces, join, path
User-Agent: Fanvil C62 2.3.752.385
P-Early-Media: supported
Allow-Events: talk
Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 263

Where:

  • 7916******* - number I calling
  • 9995 - phone number from I make call
  • 10.30.1.143 - phone local IP
  • 10.30.1.141 - asterisk local IP

Now I make call with debug from new asterisk:
<— SIP read from UDP:10.30.1.137:5060 —>
INVITE sip:7916*******@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK2836512428195665836
From: 9997 sip:9997@9997;tag=353521267
To: “7916*******” sip:7916*******@9997;user=phone
Call-ID: 292051690823212-230482114013394@10.30.1.137
CSeq: 1 INVITE
Contact: sip:9997@10.30.1.137:5060
Max-Forwards: 70
Supported: replaces, join, path
User-Agent: Fanvil C62 2.3.498.267
P-Early-Media: supported
Allow-Events: talk
Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 260

And where:

  • 7916******* - number I calling
  • 9997 - phone number from I make call
  • 10.30.1.137 - phone local IP

And there are some differences:
WORKING: From: 9995 sip:9995@10.30.1.141;tag=42719609
WORKING: To: “7916*******” sip:7916*******@10.30.1.141;user=phone

NOT_WORKING: From: 9997 sip:9997@9997;tag=353521267
NOT_WORKING: To: “7916*******” sip:7916*******@9997;user=phone

I can not understand WHY… Please help me. Also, Asterisk 13 gives next error on outbound calls:

-- Executing [79165157443@msk-test-out:1] NoOp("SIP/9997-00000004", "outgoint call!") in new stack
-- Executing [79165157443@msk-test-out:2] Dial("SIP/9997-00000004", "SIP/7916*******@150511") in new stack

Really destroying SIP dialog ‘328d48d96a15cbe25cd232d97cb9543c@192.168.0.121:5060’ Method: INVITE
[Sep 14 12:38:06] WARNING[10632][C-00000004]: app_dial.c:2381 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)
== Everyone is busy/congested at this time (1:0/0/1)
– Auto fallthrough, channel ‘SIP/9997-00000004’ status is ‘CHANUNAVAIL’

p.s. 150511 - name of trunk
p.p.s. both asterisks have SAME configurations of sips, trunks, extensions and etc.
p.p.p.s. if you need more debug information and/or sip/trunk conf info - let me know please

Hm… I dont know why, but trunk SIP is unreachable. If I change qualify to “no”, then it will be unmonitored and outbound call returns:
[Sep 14 12:51:48] NOTICE[13297][C-00000000]: chan_sip.c:23283 handle_response_invite: Failed to authenticate on INVITE to ‘“My Phone 2 Right” sip:9997@sip.zadarma.com;tag=as1f0f0bc4’

We’ll need the configuration (minus passwords) and the sip debug in order to determine what is going on.

[details=SIP.conf (not whole):] [general]
rtptimeout=60
rtpholdtimeout=600
session-timers=accept
;session-timers=refuse
session-expires=1800

session-minse=90
session-refresher=uas

context=public                  ; Default context for incoming calls. Defaults to 'default'
limitonpeers=yes
allowguest=no                  ; Allow or reject guest calls (default is yes)[/details]

[details=SIP_PHONES.conf] sysadm
deny=0.0.0.0/0.0.0.0
secret=password
dtmfmode=rfc2833
canreinvite=no
context=msk-test-out
nat=no
host=dynamic
type=friend
port=5060
qualify=yes
callgroup=33
pickupgroup=33
disallow=all
allow=g729
allow=alaw
permit=0.0.0.0/0.0.0.0
call-limit=50
directmedia=yes

[9997](sysadm)
secret=4321
dial=SIP/9997
description=Peter
mailbox=9997@device
callerid="Mans Phone 2 Right"<9997>[/details]

[details=SIP_TRUNK.CONF] register=>150511:password@sip.zadarma.com

[150511]
type=friend
context=msk-test-out
dtmfmode=rfc2833
canreinvite=no
insecure=port,invite
fromdomain=sip.zadarma.com
host=sip.zadarma.com
disallow=all
allow=ulaw,alaw
username=*123 (changed)*
trunkname=*123 (changed)*
secret=*password (changed)*
qualify=400
directmedia=yes[/details]

[details=extensions.conf] [msk-test-out]
exten => _7XXXXXXXXXX,1,NoOp(outgoint call!)
same => n,Dial(SIP/${EXTEN}@150511)
[/details]

Debug text from asterisk 13.4 (new) for sip 9997 (when I making outbound call) - NOT WORKING

<— SIP read from UDP:10.30.1.137:5060 —>
INVITE sip:79165157443@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK20756267642246915542
From: 9997 sip:9997@9997;tag=1943821779
To: “79165157443” sip:79165157443@9997;user=phone
Call-ID: 1515125555042-3396856724625@10.30.1.137
CSeq: 1 INVITE
Contact: sip:9997@10.30.1.137:5060
Max-Forwards: 70
Supported: replaces, join, path
User-Agent: Fanvil C62 2.3.498.267
P-Early-Media: supported
Allow-Events: talk
Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 261

v=0
o=9997 638732438 199567457 IN IP4 10.30.1.137
s=A conversation
c=IN IP4 10.30.1.137
t=0 0
m=audio 10330 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
<------------->
— (15 headers 12 lines) —
Sending to 10.30.1.137:5060 (no NAT)
Sending to 10.30.1.137:5060 (no NAT)
Using INVITE request as basis request - 1515125555042-3396856724625@10.30.1.137
Found peer ‘9997’ for ‘9997’ from 10.30.1.137:5060

<— Reliably Transmitting (no NAT) to 10.30.1.137:5060 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK20756267642246915542;received=10.30.1.137
From: 9997 sip:9997@9997;tag=1943821779
To: “79165157443” sip:79165157443@9997;user=phone;tag=as7577e0ca
Call-ID: 1515125555042-3396856724625@10.30.1.137
CSeq: 1 INVITE
Server: Asterisk PBX 13.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="5118ddff"
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘1515125555042-3396856724625@10.30.1.137’ in 6400 ms (Method: INVITE)

<— SIP read from UDP:10.30.1.137:5060 —>
ACK sip:79165157443@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK20756267642246915542
From: 9997 sip:9997@9997;tag=1943821779
To: “79165157443” sip:79165157443@9997;user=phone;tag=as7577e0ca
Call-ID: 1515125555042-3396856724625@10.30.1.137
CSeq: 1 ACK
Contact: sip:9997@10.30.1.137:5060
Max-Forwards: 70
Content-Length: 0

<------------->
— (9 headers 0 lines) —

<— SIP read from UDP:10.30.1.137:5060 —>
INVITE sip:79165157443@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK13120176511639020328
From: 9997 sip:9997@9997;tag=1943821779
To: “79165157443” sip:79165157443@9997;user=phone
Call-ID: 1515125555042-3396856724625@10.30.1.137
CSeq: 2 INVITE
Contact: sip:9997@10.30.1.137:5060
Authorization: Digest username=“9997”, realm=“asterisk”, nonce=“5118ddff”, uri=“sip:79165157443@9997;user=phone”, response=“158d2588aac4493f612b26c00614df28”, algorithm=MD5
Max-Forwards: 70
Supported: replaces, join, path
User-Agent: Fanvil C62 2.3.498.267
P-Early-Media: supported
Allow-Events: talk
Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 261

v=0
o=9997 638732438 199567457 IN IP4 10.30.1.137
s=A conversation
c=IN IP4 10.30.1.137
t=0 0
m=audio 10330 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
<------------->
— (16 headers 12 lines) —
Sending to 10.30.1.137:5060 (no NAT)
Using INVITE request as basis request - 1515125555042-3396856724625@10.30.1.137
Found peer ‘9997’ for ‘9997’ from 10.30.1.137:5060
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
Found RTP audio format 8
Found RTP audio format 18
Found RTP audio format 101
Found audio description format PCMA for ID 8
Found audio description format G729 for ID 18
Found audio description format telephone-event for ID 101
Capabilities: us - (g729|alaw), peer - audio=(alaw|g729)/video=(nothing)/text=(nothing), combined - (g729|alaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 10.30.1.137:10330
Looking for 79165157443 in msk-test-out (domain 9997)
sip_route_dump: route/path hop: sip:9997@10.30.1.137:5060

<— Transmitting (no NAT) to 10.30.1.137:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK13120176511639020328;received=10.30.1.137
From: 9997 sip:9997@9997;tag=1943821779
To: “79165157443” sip:79165157443@9997;user=phone
Call-ID: 1515125555042-3396856724625@10.30.1.137
CSeq: 2 INVITE
Server: Asterisk PBX 13.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: sip:79165157443@192.168.0.121:5060
Content-Length: 0

<------------>
– Executing [79165157443@msk-test-out:1] NoOp(“SIP/9997-00000012”, “outgoint call!”) in new stack
– Executing [79165157443@msk-test-out:2] Dial(“SIP/9997-00000012”, “SIP/79165157443@150511”) in new stack
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Called SIP/79165157443@150511
[Sep 14 13:40:06] NOTICE[14403][C-0000000a]: chan_sip.c:23283 handle_response_invite: Failed to authenticate on INVITE to ‘“Mans Phone 2 Right” sip:9997@sip.zadarma.com;tag=as3bde6014’
– SIP/150511-00000013 is circuit-busy
== Everyone is busy/congested at this time (1:0/1/0)
– Auto fallthrough, channel ‘SIP/9997-00000012’ status is ‘CONGESTION’

<— Reliably Transmitting (no NAT) to 10.30.1.137:5060 —>
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK13120176511639020328;received=10.30.1.137
From: 9997 sip:9997@9997;tag=1943821779
To: “79165157443” sip:79165157443@9997;user=phone;tag=as25ea52cb
Call-ID: 1515125555042-3396856724625@10.30.1.137
CSeq: 2 INVITE
Server: Asterisk PBX 13.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
X-Asterisk-HangupCause: Call Rejected
X-Asterisk-HangupCauseCode: 21
Content-Length: 0

<------------>

<— SIP read from UDP:10.30.1.137:5060 —>
ACK sip:79165157443@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK13120176511639020328
From: 9997 sip:9997@9997;tag=1943821779
To: “79165157443” sip:79165157443@9997;user=phone;tag=as25ea52cb
Call-ID: 1515125555042-3396856724625@10.30.1.137
CSeq: 2 ACK
Contact: sip:9997@10.30.1.137:5060
Max-Forwards: 70
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Really destroying SIP dialog ‘1515125555042-3396856724625@10.30.1.137’ Method: ACK[/details]

[details=Debug text from asterisk 11.6 (old) - EVERYTING OK]<— SIP read from UDP:10.30.1.143:5060 —>
INVITE sip:79165157443@10.30.1.141;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK1863526357288857172
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 1 INVITE
Contact: sip:9995@10.30.1.143:5060
Max-Forwards: 70
Supported: replaces, join, path
User-Agent: Fanvil C62 2.3.752.385
P-Early-Media: supported
Allow-Events: talk
Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 262

v=0
o=9995 1818128517 279479643 IN IP4 10.30.1.143
s=A conversation
c=IN IP4 10.30.1.143
t=0 0
m=audio 10048 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
<------------->
— (15 headers 12 lines) —
Sending to 10.30.1.143:5060 (no NAT)
Sending to 10.30.1.143:5060 (no NAT)
Using INVITE request as basis request - 21314320024181-192819468981@10.30.1.143
Found peer ‘9995’ for ‘9995’ from 10.30.1.143:5060

<— Reliably Transmitting (no NAT) to 10.30.1.143:5060 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK1863526357288857172;received=10.30.1.143
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone;tag=as2995b89a
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 1 INVITE
Server: Asterisk PBX 11.6-cert2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="32f5cd44"
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘21314320024181-192819468981@10.30.1.143’ in 6400 ms (Method: INVITE)

<— SIP read from UDP:10.30.1.143:5060 —>
ACK sip:79165157443@10.30.1.141;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK1863526357288857172
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone;tag=as2995b89a
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 1 ACK
Contact: sip:9995@10.30.1.143:5060
Max-Forwards: 70
Content-Length: 0

<------------->
— (9 headers 0 lines) —

<— SIP read from UDP:10.30.1.143:5060 —>
INVITE sip:79165157443@10.30.1.141;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK2866916640229912295
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 2 INVITE
Contact: sip:9995@10.30.1.143:5060
Authorization: Digest username=“9995”, realm=“asterisk”, nonce=“32f5cd44”, uri="sip:79165157443@10.30.1.141;user=phone", response=“84250c92826070f7ce9e359fd4eba7f9”, algorithm=MD5
Max-Forwards: 70
Supported: replaces, join, path
User-Agent: Fanvil C62 2.3.752.385
P-Early-Media: supported
Allow-Events: talk
Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 262

v=0
o=9995 1818128517 279479643 IN IP4 10.30.1.143
s=A conversation
c=IN IP4 10.30.1.143
t=0 0
m=audio 10048 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
<------------->
— (16 headers 12 lines) —
Sending to 10.30.1.143:5060 (no NAT)
Using INVITE request as basis request - 21314320024181-192819468981@10.30.1.143
Found peer ‘9995’ for ‘9995’ from 10.30.1.143:5060
Found RTP audio format 8
Found RTP audio format 18
Found RTP audio format 101
Found audio description format PCMA for ID 8
Found audio description format G729 for ID 18
Found audio description format telephone-event for ID 101
Capabilities: us - (alaw|g729), peer - audio=(alaw|g729)/video=(nothing)/text=(nothing), combined - (alaw|g729)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 10.30.1.143:10048
Looking for 79165157443 in msk-test-out (domain 10.30.1.141)
list_route: hop: sip:9995@10.30.1.143:5060

<— Transmitting (no NAT) to 10.30.1.143:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK2866916640229912295;received=10.30.1.143
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 2 INVITE
Server: Asterisk PBX 11.6-cert2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Contact: sip:79165157443@10.30.1.141:5060
Content-Length: 0

<------------>

<— SIP read from UDP:10.30.1.143:5060 —>
CANCEL sip:79165157443@10.30.1.141;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK2866916640229912295
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 2 CANCEL
Max-Forwards: 70
User-Agent: Fanvil C62 2.3.752.385
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Sending to 10.30.1.143:5060 (no NAT)

<— Reliably Transmitting (no NAT) to 10.30.1.143:5060 —>
SIP/2.0 487 Request Terminated
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK2866916640229912295;received=10.30.1.143
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone;tag=as0265afe8
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 2 INVITE
Server: Asterisk PBX 11.6-cert2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0

<------------>

<— Transmitting (no NAT) to 10.30.1.143:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK2866916640229912295;received=10.30.1.143
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone;tag=as0265afe8
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 2 CANCEL
Server: Asterisk PBX 11.6-cert2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0

<------------>

<— SIP read from UDP:10.30.1.143:5060 —>
ACK sip:79165157443@10.30.1.141;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.143:5060;branch=z9hG4bK2866916640229912295
From: 9995 sip:9995@10.30.1.141;tag=2042624222
To: “79165157443” sip:79165157443@10.30.1.141;user=phone;tag=as0265afe8
Call-ID: 21314320024181-192819468981@10.30.1.143
CSeq: 2 ACK
Max-Forwards: 70
Content-Length: 0

<------------->
— (8 headers 0 lines) —
Really destroying SIP dialog ‘21314320024181-192819468981@10.30.1.143’ Method: ACK

Both asterisks have same configs.

Are you limiting the debug… because I don’t see any sip messages for your outgoing call attempt, just incoming.

I limited by “sip set debug peer PEER_NAME”. Shall I make whole debug without “peer PEER_NAME”?

Yes, that would be more useful.

I think asterisk tries make call to mobile phone via SIP of real phone instead of TRUNK…

[details=Asterisk 13.4 debug]test_pbx*CLI> sip set debug on
SIP Debugging enabled

<--- SIP read from UDP:10.30.1.138:56032 --->

<------------->

<--- SIP read from UDP:10.30.1.137:5060 --->
INVITE sip:79165157443@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK1126019946365411618
From: 9997 <sip:9997@9997>;tag=2667919259
To: "79165157443" <sip:79165157443@9997;user=phone>
Call-ID: 156071691620432-17914465126364@10.30.1.137
CSeq: 1 INVITE
Contact: <sip:9997@10.30.1.137:5060>
Max-Forwards: 70
Supported: replaces, join, path
User-Agent: Fanvil C62 2.3.498.267
P-Early-Media: supported
Allow-Events: talk
Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 262

v=0
o=9997 1083525097 225817361 IN IP4 10.30.1.137
s=A conversation
c=IN IP4 10.30.1.137
t=0 0
m=audio 10346 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
<------------->
--- (15 headers 12 lines) ---
Sending to 10.30.1.137:5060 (no NAT)
Sending to 10.30.1.137:5060 (no NAT)
Using INVITE request as basis request - 156071691620432-17914465126364@10.30.1.137
Found peer '9997' for '9997' from 10.30.1.137:5060

<--- Reliably Transmitting (no NAT) to 10.30.1.137:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK1126019946365411618;received=10.30.1.137
From: 9997 <sip:9997@9997>;tag=2667919259
To: "79165157443" <sip:79165157443@9997;user=phone>;tag=as17cee168
Call-ID: 156071691620432-17914465126364@10.30.1.137
CSeq: 1 INVITE
Server: Asterisk PBX 13.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="23355037"
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog '156071691620432-17914465126364@10.30.1.137' in 6400 ms (Method: INVITE)

<--- SIP read from UDP:10.30.1.137:5060 --->
ACK sip:79165157443@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK1126019946365411618
From: 9997 <sip:9997@9997>;tag=2667919259
To: "79165157443" <sip:79165157443@9997;user=phone>;tag=as17cee168
Call-ID: 156071691620432-17914465126364@10.30.1.137
CSeq: 1 ACK
Contact: <sip:9997@10.30.1.137:5060>
Max-Forwards: 70
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---

<--- SIP read from UDP:10.30.1.137:5060 --->
INVITE sip:79165157443@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK112819761878226383
From: 9997 <sip:9997@9997>;tag=2667919259
To: "79165157443" <sip:79165157443@9997;user=phone>
Call-ID: 156071691620432-17914465126364@10.30.1.137
CSeq: 2 INVITE
Contact: <sip:9997@10.30.1.137:5060>
Authorization: Digest username="9997", realm="asterisk", nonce="23355037", uri="sip:79165157443@9997;user=phone", response="387a23aa0ff963a01d5ade00ab3f2b93", algorithm=MD5
Max-Forwards: 70
Supported: replaces, join, path
User-Agent: Fanvil C62 2.3.498.267
P-Early-Media: supported
Allow-Events: talk
Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 262

v=0
o=9997 1083525097 225817361 IN IP4 10.30.1.137
s=A conversation
c=IN IP4 10.30.1.137
t=0 0
m=audio 10346 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
<------------->
--- (16 headers 12 lines) ---
Sending to 10.30.1.137:5060 (no NAT)
Using INVITE request as basis request - 156071691620432-17914465126364@10.30.1.137
Found peer '9997' for '9997' from 10.30.1.137:5060
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
Found RTP audio format 8
Found RTP audio format 18
Found RTP audio format 101
Found audio description format PCMA for ID 8
Found audio description format G729 for ID 18
Found audio description format telephone-event for ID 101
Capabilities: us - (g729|alaw), peer - audio=(alaw|g729)/video=(nothing)/text=(nothing), combined - (g729|alaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 10.30.1.137:10346
Looking for 79165157443 in msk-test-out (domain 9997)
sip_route_dump: route/path hop: <sip:9997@10.30.1.137:5060>

<--- Transmitting (no NAT) to 10.30.1.137:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK112819761878226383;received=10.30.1.137
From: 9997 <sip:9997@9997>;tag=2667919259
To: "79165157443" <sip:79165157443@9997;user=phone>
Call-ID: 156071691620432-17914465126364@10.30.1.137
CSeq: 2 INVITE
Server: Asterisk PBX 13.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:79165157443@192.168.0.121:5060>
Content-Length: 0


<------------>
    -- Executing [79165157443@msk-test-out:1] NoOp("SIP/9997-00000020", "outgoint call!") in new stack
    -- Executing [79165157443@msk-test-out:2] Dial("SIP/9997-00000020", "SIP/79165157443@150511") in new stack
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
Audio is at 10336
Adding codec ulaw to SDP
Adding codec alaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 185.45.152.161:5060:
INVITE sip:79165157443@sip.zadarma.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK12d0fdad
Max-Forwards: 70
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>
Contact: <sip:9997@192.168.0.121:5060>
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 102 INVITE
User-Agent: Asterisk PBX 13.4.0
Date: Wed, 14 Sep 2016 11:15:05 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 263

v=0
o=root 651708801 651708801 IN IP4 192.168.0.121
s=Asterisk PBX 13.4.0
c=IN IP4 192.168.0.121
t=0 0
m=audio 10336 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---
    -- Called SIP/79165157443@150511

<--- SIP read from UDP:185.45.152.161:5060 --->
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK12d0fdad;rport=53718;received=62.140.236.228
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>;tag=bcc9de9cd72655a99664e3be44d308f3.27f8
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 102 INVITE
Proxy-Authenticate: Digest realm="sip.zadarma.com", nonce="V9kyZVfZMTkbqHcQSIkdkXXQrfaXGvcr", qop="auth"
Server: Zadarma server
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---
Transmitting (no NAT) to 185.45.152.161:5060:
ACK sip:79165157443@sip.zadarma.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK12d0fdad
Max-Forwards: 70
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>;tag=bcc9de9cd72655a99664e3be44d308f3.27f8
Contact: <sip:9997@192.168.0.121:5060>
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 102 ACK
User-Agent: Asterisk PBX 13.4.0
Content-Length: 0


---
Audio is at 10336
Adding codec ulaw to SDP
Adding codec alaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 185.45.152.161:5060:
INVITE sip:79165157443@sip.zadarma.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK5a0b7d5c
Max-Forwards: 70
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>
Contact: <sip:9997@192.168.0.121:5060>
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 103 INVITE
User-Agent: Asterisk PBX 13.4.0
Proxy-Authorization: Digest username="150511", realm="sip.zadarma.com", algorithm=MD5, uri="sip:79165157443@sip.zadarma.com", nonce="V9kyZVfZMTkbqHcQSIkdkXXQrfaXGvcr", response="2e3d5d9244cdc2a7b38403deaeafece5", qop=auth, cnonce="13536acd", nc=00000001
Date: Wed, 14 Sep 2016 11:15:05 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 263

v=0
o=root 651708801 651708802 IN IP4 192.168.0.121
s=Asterisk PBX 13.4.0
c=IN IP4 192.168.0.121
t=0 0
m=audio 10336 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---

<--- SIP read from UDP:185.45.152.161:5060 --->
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK5a0b7d5c;rport=53718;received=62.140.236.228
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>;tag=bcc9de9cd72655a99664e3be44d308f3.fa97
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 103 INVITE
Proxy-Authenticate: Digest realm="sip.zadarma.com", nonce="V9kyZVfZMTkbqHcQSIkdkXXQrfaXGvcr", qop="auth"
Server: Zadarma server
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---
Transmitting (no NAT) to 185.45.152.161:5060:
ACK sip:79165157443@sip.zadarma.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK5a0b7d5c
Max-Forwards: 70
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>;tag=bcc9de9cd72655a99664e3be44d308f3.fa97
Contact: <sip:9997@192.168.0.121:5060>
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 103 ACK
User-Agent: Asterisk PBX 13.4.0
Content-Length: 0


---
Audio is at 10336
Adding codec ulaw to SDP
Adding codec alaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 185.45.152.161:5060:
INVITE sip:79165157443@sip.zadarma.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK6ee84757
Max-Forwards: 70
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>
Contact: <sip:9997@192.168.0.121:5060>
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 104 INVITE
User-Agent: Asterisk PBX 13.4.0
Proxy-Authorization: Digest username="150511", realm="sip.zadarma.com", algorithm=MD5, uri="sip:79165157443@sip.zadarma.com", nonce="V9kyZVfZMTkbqHcQSIkdkXXQrfaXGvcr", response="33a5850ca1ffd5d63dea390e9e6401b9", qop=auth, cnonce="3069f451", nc=00000002
Date: Wed, 14 Sep 2016 11:15:05 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 263

v=0
o=root 651708801 651708803 IN IP4 192.168.0.121
s=Asterisk PBX 13.4.0
c=IN IP4 192.168.0.121
t=0 0
m=audio 10336 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---

<--- SIP read from UDP:185.45.152.161:5060 --->
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK6ee84757;rport=53718;received=62.140.236.228
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>;tag=bcc9de9cd72655a99664e3be44d308f3.ecca
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 104 INVITE
Proxy-Authenticate: Digest realm="sip.zadarma.com", nonce="V9kyZVfZMTkbqHcQSIkdkXXQrfaXGvcr", qop="auth"
Server: Zadarma server
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---
Transmitting (no NAT) to 185.45.152.161:5060:
ACK sip:79165157443@sip.zadarma.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK6ee84757
Max-Forwards: 70
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>;tag=bcc9de9cd72655a99664e3be44d308f3.ecca
Contact: <sip:9997@192.168.0.121:5060>
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 104 ACK
User-Agent: Asterisk PBX 13.4.0
Content-Length: 0


---
Audio is at 10336
Adding codec ulaw to SDP
Adding codec alaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 185.45.152.161:5060:
INVITE sip:79165157443@sip.zadarma.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK5ce42971
Max-Forwards: 70
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>
Contact: <sip:9997@192.168.0.121:5060>
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 105 INVITE
User-Agent: Asterisk PBX 13.4.0
Proxy-Authorization: Digest username="150511", realm="sip.zadarma.com", algorithm=MD5, uri="sip:79165157443@sip.zadarma.com", nonce="V9kyZVfZMTkbqHcQSIkdkXXQrfaXGvcr", response="c62ea835dbe643bf5f6cc0996e517e01", qop=auth, cnonce="384d7279", nc=00000003
Date: Wed, 14 Sep 2016 11:15:05 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 263

v=0
o=root 651708801 651708804 IN IP4 192.168.0.121
s=Asterisk PBX 13.4.0
c=IN IP4 192.168.0.121
t=0 0
m=audio 10336 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---

<--- SIP read from UDP:185.45.152.161:5060 --->
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK5ce42971;rport=53718;received=62.140.236.228
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>;tag=bcc9de9cd72655a99664e3be44d308f3.4e40
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 105 INVITE
Proxy-Authenticate: Digest realm="sip.zadarma.com", nonce="V9kyZVfZMTkbqHcQSIkdkXXQrfaXGvcr", qop="auth"
Server: Zadarma server
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---
Transmitting (no NAT) to 185.45.152.161:5060:
ACK sip:79165157443@sip.zadarma.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.121:5060;branch=z9hG4bK5ce42971
Max-Forwards: 70
From: "Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001
To: <sip:79165157443@sip.zadarma.com>;tag=bcc9de9cd72655a99664e3be44d308f3.4e40
Contact: <sip:9997@192.168.0.121:5060>
Call-ID: 5ccb883647807f1f3607700846a4ac54@sip.zadarma.com
CSeq: 105 ACK
User-Agent: Asterisk PBX 13.4.0
Content-Length: 0


---
[Sep 14 14:15:05] NOTICE[14403][C-00000012]: chan_sip.c:23283 handle_response_invite: Failed to authenticate on INVITE to '"Mans Phone 2 Right" <sip:9997@sip.zadarma.com>;tag=as2e260001'
    -- SIP/150511-00000021 is circuit-busy
  == Everyone is busy/congested at this time (1:0/1/0)
    -- Auto fallthrough, channel 'SIP/9997-00000020' status is 'CONGESTION'

<--- Reliably Transmitting (no NAT) to 10.30.1.137:5060 --->
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK112819761878226383;received=10.30.1.137
From: 9997 <sip:9997@9997>;tag=2667919259
To: "79165157443" <sip:79165157443@9997;user=phone>;tag=as5e9a1cdb
Call-ID: 156071691620432-17914465126364@10.30.1.137
CSeq: 2 INVITE
Server: Asterisk PBX 13.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
X-Asterisk-HangupCause: Call Rejected
X-Asterisk-HangupCauseCode: 21
Content-Length: 0


<------------>
Really destroying SIP dialog '5ccb883647807f1f3607700846a4ac54@sip.zadarma.com' Method: INVITE

<--- SIP read from UDP:10.30.1.137:5060 --->
ACK sip:79165157443@9997;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.30.1.137:5060;branch=z9hG4bK112819761878226383
From: 9997 <sip:9997@9997>;tag=2667919259
To: "79165157443" <sip:79165157443@9997;user=phone>;tag=as5e9a1cdb
Call-ID: 156071691620432-17914465126364@10.30.1.137
CSeq: 2 ACK
Contact: <sip:9997@10.30.1.137:5060>
Max-Forwards: 70
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---
Really destroying SIP dialog '156071691620432-17914465126364@10.30.1.137' Method: ACK
test_pbx*CLI> sip set debug off
SIP Debugging Disabled
test_pbx*CLI>[/details]

What happens if you set the fromuser option in the sip.conf entry for your trunk to your username for the trunk?

Oh my god… It works now! With “fromuser” on trunk sip! Thank you SO MUCH! I spent 2 days per 8-9 hours to configure fresh asterisk with old one settings! And missed this string when I modified trunk sip (because I was thinking it could has changes in new asterisk version). Thank you! Very very much!