New trunk setup not working as expected

Hi,

I’m struggling to setup an additional trunk with a different provider.

We’ve been given a 100 DID block to use with our new trunk provider. We’ve setup and registered the trunk and setup the new inbound routes. Upon initial testing we thought it was working as expected as the first number (0865562700) in our DID block gets directed to our IVR, but when testing another DID (0865562702) it appears to be processed as if it’s a call coming in for 0865562700 and goes to the IVR instead of being directed to an extension.

Below Asterisk logging of when I call 0865562702 and it being processed as 0865562700.

[May 29 12:53:49] Asterisk 13.18.0, Copyright © 1999 - 2014, Digium, Inc. and others.
[May 29 12:53:49] Created by Mark Spencer <markster@ digium. com>
[May 29 12:53:49] Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
[May 29 12:53:49] This is free software, with components licensed under the GNU General Public
[May 29 12:53:49] License version 2 and other licenses; you are welcome to redistribute it under
[May 29 12:53:49] certain conditions. Type ‘core show license’ for details.
[May 29 12:53:49] =========================================================================
[May 29 12:53:49] Connected to Asterisk 13.18.0 currently running on pbx (pid = 2022)
[May 29 12:53:50] – Executing [79@from-internal:8] Macro(“SIP/134-00000094”, “hangupcall,”) in new stack
[May 29 12:53:50] – Executing [s@macro-hangupcall:1] GotoIf(“SIP/134-00000094”, “1?theend”) in new stack
[May 29 12:53:50] – Goto (macro-hangupcall,s,3)
[May 29 12:53:50] – Executing [s@macro-hangupcall:3] ExecIf(“SIP/134-00000094”, “0?Set(CDR(recordingfile)=)”) in new stack
[May 29 12:53:50] – Executing [s@macro-hangupcall:4] Hangup(“SIP/134-00000094”, “”) in new stack
[May 29 12:53:50] == Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘SIP/134-00000094’ in macro ‘hangupcall’
[May 29 12:53:50] == Spawn extension (from-internal, 79, 8) exited non-zero on ‘SIP/134-00000094’
[May 29 12:53:50] – Executing [h@from-internal:1] Macro(“SIP/134-00000094”, “hangupcall”) in new stack
[May 29 12:53:50] – Executing [s@macro-hangupcall:1] GotoIf(“SIP/134-00000094”, “1?theend”) in new stack
[May 29 12:53:50] – Goto (macro-hangupcall,s,3)
[May 29 12:53:50] – Executing [s@macro-hangupcall:3] ExecIf(“SIP/134-00000094”, “0?Set(CDR(recordingfile)=)”) in new stack
[May 29 12:53:50] – Executing [s@macro-hangupcall:4] Hangup(“SIP/134-00000094”, “”) in new stack
[May 29 12:53:50] == Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘SIP/134-00000094’ in macro ‘hangupcall’
[May 29 12:53:50] == Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/134-00000094’
[May 29 12:53:50] == Extension Changed 134[ext-local] new state Idle for Notify User 111
[May 29 12:53:50] == Extension Changed 134[ext-local] new state Idle for Notify User 101
[May 29 12:53:50] == Extension Changed 134[ext-local] new state Idle for Notify User 170
[May 29 12:53:57] == Using SIP RTP TOS bits 184
[May 29 12:53:57] == Using SIP RTP CoS mark 5
[May 29 12:53:57] – Executing [0865562700@from-trunk-sip-Vocus:1] Set(“SIP/Vocus-00000095”, “GROUP()=OUT_8”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk-sip-Vocus:2] Goto(“SIP/Vocus-00000095”, “from-trunk,0865562700,1”) in new stack
[May 29 12:53:57] – Goto (from-trunk,0865562700,1)
[May 29 12:53:57] – Executing [0865562700@from-trunk:1] Set(“SIP/Vocus-00000095”, “__DIRECTION=INBOUND”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:2] Gosub(“SIP/Vocus-00000095”, “sub-record-check,s,1(in,0865562700,dontcare)”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:1] GotoIf(“SIP/Vocus-00000095”, “0?initialized”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:2] Set(“SIP/Vocus-00000095”, “__REC_STATUS=INITIALIZED”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:3] Set(“SIP/Vocus-00000095”, “NOW=1527569637”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:4] Set(“SIP/Vocus-00000095”, “__DAY=29”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:5] Set(“SIP/Vocus-00000095”, “__MONTH=05”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:6] Set(“SIP/Vocus-00000095”, “__YEAR=2018”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:7] Set(“SIP/Vocus-00000095”, “__TIMESTR=20180529-125357”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:8] Set(“SIP/Vocus-00000095”, “__FROMEXTEN=unknown”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:9] Set(“SIP/Vocus-00000095”, “__MON_FMT=wav”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:10] NoOp(“SIP/Vocus-00000095”, “Recordings initialized”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:11] ExecIf(“SIP/Vocus-00000095”, “0?Set(ARG3=dontcare)”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:12] Set(“SIP/Vocus-00000095”, “REC_POLICY_MODE_SAVE=”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:13] ExecIf(“SIP/Vocus-00000095”, “0?Set(REC_STATUS=NO)”) in new stack
[May 29 12:53:57] – Executing [s@sub-record-check:14] GotoIf(“SIP/Vocus-00000095”, “2?checkaction”) in new stack
[May 29 12:53:57] – Goto (sub-record-check,s,17)
[May 29 12:53:57] – Executing [s@sub-record-check:17] GotoIf(“SIP/Vocus-00000095”, “1?sub-record-check,in,1”) in new stack
[May 29 12:53:57] – Goto (sub-record-check,in,1)
[May 29 12:53:57] – Executing [in@sub-record-check:1] NoOp(“SIP/Vocus-00000095”, “Inbound Recording Check to 0865562700”) in new stack
[May 29 12:53:57] – Executing [in@sub-record-check:2] Set(“SIP/Vocus-00000095”, “FROMEXTEN=unknown”) in new stack
[May 29 12:53:57] – Executing [in@sub-record-check:3] ExecIf(“SIP/Vocus-00000095”, “10?Set(FROMEXTEN=mobile_number)”) in new stack
[May 29 12:53:57] – Executing [in@sub-record-check:4] Gosub(“SIP/Vocus-00000095”, “recordcheck,1(dontcare,in,0865562700)”) in new stack
[May 29 12:53:57] – Executing [recordcheck@sub-record-check:1] NoOp(“SIP/Vocus-00000095”, “Starting recording check against dontcare”) in new stack
[May 29 12:53:57] – Executing [recordcheck@sub-record-check:2] Goto(“SIP/Vocus-00000095”, “dontcare”) in new stack
[May 29 12:53:57] – Goto (sub-record-check,recordcheck,3)
[May 29 12:53:57] – Executing [recordcheck@sub-record-check:3] Return(“SIP/Vocus-00000095”, “”) in new stack
[May 29 12:53:57] – Executing [in@sub-record-check:5] Return(“SIP/Vocus-00000095”, “”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:3] Gosub(“SIP/Vocus-00000095”, “app-blacklist-check,s,1()”) in new stack
[May 29 12:53:57] – Executing [s@app-blacklist-check:1] GotoIf(“SIP/Vocus-00000095”, “0?blacklisted”) in new stack
[May 29 12:53:57] – Executing [s@app-blacklist-check:2] Set(“SIP/Vocus-00000095”, “CALLED_BLACKLIST=1”) in new stack
[May 29 12:53:57] – Executing [s@app-blacklist-check:3] Return(“SIP/Vocus-00000095”, “”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:4] Set(“SIP/Vocus-00000095”, “__FROM_DID=0865562700”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:5] Set(“SIP/Vocus-00000095”, “CDR(did)=0865562700”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:6] ExecIf(“SIP/Vocus-00000095”, “1 ?Set(CALLERID(name)=mobile_number)”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:7] Set(“SIP/Vocus-00000095”, “__MOHCLASS=”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:8] Set(“SIP/Vocus-00000095”, “__REVERSAL_REJECT=FALSE”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:9] GotoIf(“SIP/Vocus-00000095”, “1?post-reverse-charge”) in new stack
[May 29 12:53:57] – Goto (from-trunk,0865562700,11)
[May 29 12:53:57] – Executing [0865562700@from-trunk:11] NoOp(“SIP/Vocus-00000095”, “”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:12] Set(“SIP/Vocus-00000095”, “__CALLINGNAMEPRES_SV=allowed_not_screened”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:13] Set(“SIP/Vocus-00000095”, “__CALLINGNUMPRES_SV=allowed_not_screened”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:14] Set(“SIP/Vocus-00000095”, “CALLERID(name-pres)=allowed_not_screened”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:15] Set(“SIP/Vocus-00000095”, “CALLERID(num-pres)=allowed_not_screened”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:16] NoOp(“SIP/Vocus-00000095”, “CallerID Entry Point”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:17] Set(“SIP/Vocus-00000095”, “__CRM_DIRECTION=INBOUND”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:18] Set(“SIP/Vocus-00000095”, “__CRM_SOURCE=mobile_number”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:19] Set(“SIP/Vocus-00000095”, “__CRM_LINKEDID=1527569637.1136”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:20] ExecIf(“SIP/Vocus-00000095”, “1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)”) in new stack
[May 29 12:53:57] – Executing [0865562700@from-trunk:21] Goto(“SIP/Vocus-00000095”, “timeconditions,21,1”) in new stack
[May 29 12:53:57] – Goto (timeconditions,21,1)
[May 29 12:53:57] – Executing [21@timeconditions:1] Set(“SIP/Vocus-00000095”, “DB(TC/21/INUSESTATE)=INUSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:2] Set(“SIP/Vocus-00000095”, “DB(TC/21/NOT_INUSESTATE)=NOT_INUSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:3] NoOp(“SIP/Vocus-00000095”, “TIMENOW: 12:53,Tue,29,May”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:4] NoOp(“SIP/Vocus-00000095”, “TIMEMATCHED: FALSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:5] GotoIfTime(“SIP/Vocus-00000095”, “04:30-19:30,mon,30,mar?truestate”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:6] NoOp(“SIP/Vocus-00000095”, “TIMENOW: 12:53,Tue,29,May”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:7] NoOp(“SIP/Vocus-00000095”, “TIMEMATCHED: FALSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:8] GotoIfTime(“SIP/Vocus-00000095”, “02:30-19:30,26,jan?truestate”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:9] NoOp(“SIP/Vocus-00000095”, “TIMENOW: 12:53,Tue,29,May”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:10] NoOp(“SIP/Vocus-00000095”, “TIMEMATCHED: FALSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:11] GotoIfTime(“SIP/Vocus-00000095”, “02:30-19:29,26,dec?truestate”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:12] NoOp(“SIP/Vocus-00000095”, “TIMENOW: 12:53,Tue,29,May”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:13] NoOp(“SIP/Vocus-00000095”, “TIMEMATCHED: FALSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:14] GotoIfTime(“SIP/Vocus-00000095”, “02:30-19:29,1,jan?truestate") in new stack
[May 29 12:53:57] – Executing [21@timeconditions:15] NoOp(“SIP/Vocus-00000095”, “TIMENOW: 12:53,Tue,29,May”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:16] NoOp(“SIP/Vocus-00000095”, “TIMEMATCHED: FALSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:17] GotoIfTime(“SIP/Vocus-00000095”, “03:59-19:00,25,apr?truestate”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:18] NoOp(“SIP/Vocus-00000095”, “TIMENOW: 12:53,Tue,29,May”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:19] NoOp(“SIP/Vocus-00000095”, “TIMEMATCHED: FALSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:20] GotoIfTime(“SIP/Vocus-00000095”, “03:30-19:00,26,jan?truestate”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:21] NoOp(“SIP/Vocus-00000095”, “TIMENOW: 12:53,Tue,29,May”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:22] NoOp(“SIP/Vocus-00000095”, “TIMEMATCHED: FALSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:23] GotoIfTime(“SIP/Vocus-00000095”, “03:30-19:30,mon,2,apr?truestate”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:24] GotoIf(“SIP/Vocus-00000095”, “0?truegoto”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:25] ExecIf(“SIP/Vocus-00000095”, “0?Set(DB(TC/21)=)”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:26] Set(“SIP/Vocus-00000095”, “DEVICE_STATE(Custom:TC21)=INUSE”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:27] ExecIf(“SIP/Vocus-00000095”, “0?Set(DEVICE_STATE(Custom:TCSTICKY)=INUSE)”) in new stack
[May 29 12:53:57] – Executing [21@timeconditions:28] GotoIf(“SIP/Vocus-00000095”, “1?timeconditions,17,1”) in new stack
[May 29 12:53:57] – Goto (timeconditions,17,1)
[May 29 12:53:57] – Executing [17@timeconditions:1] Set(“SIP/Vocus-00000095”, “DB(TC/17/INUSESTATE)=INUSE”) in new stack
[May 29 12:53:57] – Executing [17@timeconditions:2] Set(“SIP/Vocus-00000095”, “DB(TC/17/NOT_INUSESTATE)=NOT_INUSE”) in new stack
[May 29 12:53:57] – Executing [17@timeconditions:3] NoOp(“SIP/Vocus-00000095”, “TIMENOW: 12:53,Tue,29,May”) in new stack
[May 29 12:53:57] – Executing [17@timeconditions:4] NoOp(“SIP/Vocus-00000095”, “TIMEMATCHED: TRUE”) in new stack
[May 29 12:53:57] – Executing [17@timeconditions:5] GotoIfTime(“SIP/Vocus-00000095”, "06:30-16:00,mon-fri,*?truestate”) in new stack
[May 29 12:53:57] – Goto (timeconditions,17,14)
[May 29 12:53:57] – Executing [17@timeconditions:14] GotoIf(“SIP/Vocus-00000095”, “0?falsegoto”) in new stack
[May 29 12:53:57] – Executing [17@timeconditions:15] ExecIf(“SIP/Vocus-00000095”, “0?Set(DB(TC/17)=)”) in new stack
[May 29 12:53:57] – Executing [17@timeconditions:16] Set(“SIP/Vocus-00000095”, “DEVICE_STATE(Custom:TC17)=NOT_INUSE”) in new stack
[May 29 12:53:57] – Executing [17@timeconditions:17] ExecIf(“SIP/Vocus-00000095”, “0?Set(DEVICE_STATE(Custom:TCSTICKY)=INUSE)”) in new stack
[May 29 12:53:57] – Executing [17@timeconditions:18] GotoIf(“SIP/Vocus-00000095”, “1?ivr-14,s,1”) in new stack
[May 29 12:53:57] – Goto (ivr-14,s,1)
[May 29 12:53:57] – Executing [s@ivr-14:1] Set(“SIP/Vocus-00000095”, “TIMEOUT_LOOPCOUNT=0”) in new stack
[May 29 12:53:57] – Executing [s@ivr-14:2] Set(“SIP/Vocus-00000095”, “INVALID_LOOPCOUNT=0”) in new stack
[May 29 12:53:57] – Executing [s@ivr-14:3] Set(“SIP/Vocus-00000095”, “_IVR_CONTEXT_ivr-14=”) in new stack
[May 29 12:53:57] – Executing [s@ivr-14:4] Set(“SIP/Vocus-00000095”, “_IVR_CONTEXT=ivr-14”) in new stack
[May 29 12:53:57] – Executing [s@ivr-14:5] Set(“SIP/Vocus-00000095”, “__IVR_RETVM=”) in new stack
[May 29 12:53:57] – Executing [s@ivr-14:6] GotoIf(“SIP/Vocus-00000095”, “0?skip”) in new stack
[May 29 12:53:57] – Executing [s@ivr-14:7] Answer(“SIP/Vocus-00000095”, “”) in new stack
[May 29 12:53:58] – Executing [s@ivr-14:8] Wait(“SIP/Vocus-00000095”, “1”) in new stack
[May 29 12:53:59] – Executing [s@ivr-14:9] Set(“SIP/Vocus-00000095”, “IVR_MSG=custom/Main-IVR”) in new stack
[May 29 12:53:59] – Executing [s@ivr-14:10] Set(“SIP/Vocus-00000095”, “TIMEOUT(digit)=3”) in new stack
[May 29 12:53:59] – Digit timeout set to 3.000
[May 29 12:53:59] – Executing [s@ivr-14:11] ExecIf(“SIP/Vocus-00000095”, “1?Background(custom/Main-IVR)”) in new stack
[May 29 12:53:59] – <SIP/Vocus-00000095> Playing ‘custom/Main-IVR.alaw’ (language ‘en’)

Below is our trunk settings with the password changed.
Outgoing:

username=AMM-80151-Trunk
type=friend
secret=abcd123
reinvite=yes
realm=amcomvoice.ipsystems.com.au
qualify=no
port=5060
nat=yes
musiconhold=framed
insecure=very
host=amcomvoice.ipsystems.com.au
fromuser=AMM-80151-Trunk
fromdomain=amcomvoice.ipsystems.com.au
dtmfmode=rfc2833
disallow=all
canreinvite=yes
auth=md5
allow=ulaw&alaw

Incoming:

username=AMM-80151-Trunk
type=user
secret=abc123
host=amcomvoice.ipsystems.com.au
fromdomain=amcomvoice.ipsystems.com.au
context=from-trunk

Register string:
AMM-80151-Trunk:abc [email protected]/0865562700

I’m sure I’m doing something stupid. Any thoughts would be greatly appreciated!

Daniel

Amcom / Vocus is probably sending the DID number in the To: header of the incoming INVITE. You can confirm that by typing
sip set debug on
at the Asterisk command line, making a test call and viewing the SIP in the Asterisk log.

If that’s the case, changing the context from from-trunk to from-pstn-toheader will likely do what you want.

If they are sending a different format, e.g. 61865562702 or +61865562702 in that header, you’ll need to write a small custom context to fix that. Use the code in from-pstn-toheader as a guide.

1 Like

Thanks for the hints. It looks like you’re bang on the money when looking at the To: header of the incoming INVITE.

Unfortunately setting the context to from-pstn-toheader doesn’t work.

[May 30 08:50:28] <— SIP read from UDP:202.147.134.21:5060 —>
[May 30 08:50:28] INVITE sip:[email protected]:5060 SIP/2.0
[May 30 08:50:28] Via: SIP/2.0/UDP 202.147.134.21:5060;branch=z9hG4bK1rl8dl207or1kqlcu1u0.1
[May 30 08:50:28] From: <sip:mobile_number@ amcomvoice.ipsystems.com.au;user=phone>;tag=SDhsrnd01-1716511909-1527641428114-
[May 30 08:50:28] To: “865562702 865562702”<sip:0865562702@ amcomvoice.ipsystems.com.au>
[May 30 08:50:28] Call-ID: SDhsrnd01-d0e0aac9dedf721772893f5ff37a5467-au418e3
[May 30 08:50:28] CSeq: 390277194 INVITE
[May 30 08:50:28] Contact: <sip:SD4tl71-vv9pmjn1vl07h0t6in0808cjov84opsv-7@ 202.147.134.21:5060;transport=udp>
[May 30 08:50:28] P-Called-Party-ID: <sip:0865562702@ amcomvoice.ipsystems.com.au>
[May 30 08:50:28] Supported: 100rel,timer
[May 30 08:50:28] Allow: ACK,BYE,CANCEL,INFO,INVITE,OPTIONS,PRACK,REFER,NOTIFY,UPDATE
[May 30 08:50:28] Recv-Info: x-broadworks-client-session-info
[May 30 08:50:28] Accept: application/media_control+xml,application/sdp,multipart/mixed
[May 30 08:50:28] Min-SE: 90
[May 30 08:50:28] Session-Expires: 1800;refresher=uas
[May 30 08:50:28] Max-Forwards: 29
[May 30 08:50:28] Content-Type: application/sdp
[May 30 08:50:28] Content-Disposition: session;handling=required
[May 30 08:50:28] Content-Length: 273

In the end I added the context below to my /etc/asterisk/extensions_custom.conf file.

[custom-get-did-from-vocus]
exten => _.,1,Noop(Fixing DID using information from SIP TO header)
exten => _.,n,Set(pseudodid=${SIP_HEADER(To)})
exten => _.,n,Set(pseudodid=${CUT(pseudodid,@,1)})
exten => _.,n,Set(pseudodid=${CUT(pseudodid,:,2)})
exten => _.,n,Goto(from-trunk,${pseudodid},1)

Thanks for all your help Stewart1!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.