Route inbound through specific trunk


(Leadit) #1

Hello,

I have multiple trunk accounts with different DIDs and want to know if I can have the system, based on the DID that is called receive the call to the appropriate trunk? When I view the logs, no matter what I dial it is just using one trunk.


#2

That would depend on your provider’s definition of ‘trunk’, (there is often confusion as to what a ‘trunk’ is with SIP), You don’t ‘receive’ a call to a trunk, you handle a call ‘from’ a trunk, sending it to an ‘inbound route’.


(Leadit) #3

So… I don’t understand where to go next? I feel like I should be able to do an inbound route and if it matches the inbound CID then uses the appropriate trunk.


#4

There is also often confusion between CID (CallerID, the callers number) and DID (Direct Inward Dial, the number they called).

I suggest you spend some time in the WIKI link a the top of this page.


(Leadit) #5

So, in short what I am trying to do is call XXX-XXX-XXXX and it is setup as an inbound route and have it go to a specific trunk. Currently in the PBX it is going to one VOIP.MS account but it is not the correct one.


#6

You can’t change the “trunk” that a DID is assigned to from Asterisk.


(Leadit) #7

What about when I use

: @ . .*.***:5060/1234567890

Why wouldn’t it route the incoming call to this trunk?


#8

Because it doesn’t work like that. (What Trunk? ) Did you goto the WIKI yet?


(Dave Burgess) #9

For purposes of simplicity: trunks deliver calls to your PBX. From there, you sort them out by running them past every inbound route, which decides whether or not to process the call. Once it’s decided, it handles the call. The choice of what trunk gets used happens way before you get a vote.


(Leadit) #10

Hello,

Thank you for this. So it is almost sounding like this:

I have DID 1 with VOIP.MS (trunk 1) and DID 2 with VOIP.MS (trunk 2). They are both registered:

When I call DID 2 and look at my logs, it shows that it is processing on the Maricopa trunk when I want it to process on the East Mesa trunk because of billing purposes they have to be separate.

Set(“SIP/Maricopa-00000200”, “__FROM_DID=4809845645”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [4809845645@from-trunk:2] Gosub(“SIP/Maricopa-00000200”, “app-blacklist-check,s,1()”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [s@app-blacklist-check:1] GotoIf(“SIP/Maricopa-00000200”, “0?blacklisted”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [s@app-blacklist-check:2] Set(“SIP/Maricopa-00000200”, “CALLED_BLACKLIST=1”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [s@app-blacklist-check:3] Return(“SIP/Maricopa-00000200”, “”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [4809845645@from-trunk:3] Set(“SIP/Maricopa-00000200”, “CDR(did)=4809845645”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [4809845645@from-trunk:4] ExecIf(“SIP/Maricopa-00000200”, “0 ?Set(CALLERID(name)=4804183673)”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [4809845645@from-trunk:5] Set(“SIP/Maricopa-00000200”, “CHANNEL(musicclass)=default”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [4809845645@from-trunk:6] Set(“SIP/Maricopa-00000200”, “__MOHCLASS=default”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [4809845645@from-trunk:7] Set(“SIP/Maricopa-00000200”, “__CALLINGPRES_SV=allowed_not_screened”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [4809845645@from-trunk:8] Set(“SIP/Maricopa-00000200”, “CALLERPRES()=allowed_not_screened”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [4809845645@from-trunk:9] Goto(“SIP/Maricopa-00000200”, “app-announcement-4,s,1”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Goto (app-announcement-4,s,1)
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [s@app-announcement-4:1] GotoIf(“SIP/Maricopa-00000200”, “0?begin”) in new stack
[2020-11-12 08:07:37] VERBOSE[7999][C-000000e2] pbx.c: – Executing [s@app-announcement-4:2] Answer(“SIP/Maricopa-00000200”, “”) in new stack
[2020-11-12 08:07:38] VERBOSE[7999][C-000000e2] pbx.c: – Executing [s@app-announcement-4:3] Wait(“SIP/Maricopa-00000200”, “1”) in new stack
[2020-11-12 08:07:39] VERBOSE[7999][C-000000e2] pbx.c: – Executing [s@app-announcement-4:4] NoOp(“SIP/Maricopa-00000200”, “Playing announcement East Mesa Welcome”) in new stack
[2020-11-12 08:07:39] VERBOSE[7999][C-000000e2] pbx.c: – Executing [s@app-announcement-4:5] Playback(“SIP/Maricopa-00000200”, “custom/EM_Welcome,noanswer”) in new stack
[2020-11-12 08:07:39] VERBOSE[7999][C-000000e2] file.c: – <SIP/Maricopa-00000200> Playing ‘custom/EM_Welcome.slin’ (language ‘en’)
[2020-11-12 08:07:40] VERBOSE[7999][C-000000e2] pbx.c: == Spawn extension (app-announcement-4, s, 5) exited non-zero on ‘SIP/Maricopa-00000200’
[2020-11-12 08:07:42] VERBOSE[8002] manager.c: == Manager ‘admin’ logged on from 127.0.0.1
[2020-11-12 08:07:43] VERBOSE[8002] manager.c: == Manager ‘admin’ logged off from 127.0.0.1
[2020-11-12 08:08:05] VERBOSE[23792][C-000000e3] netsock2.c: == Using SIP RTP TOS bits 184
[2020-11-12 08:08:05] VERBOSE[23792][C-000000e3] netsock2.c: == Using SIP RTP CoS mark 5
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:1] Set(“SIP/Maricopa-00000201”, “__FROM_DID=5205687800”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:2] Gosub(“SIP/Maricopa-00000201”, “app-blacklist-check,s,1()”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@app-blacklist-check:1] GotoIf(“SIP/Maricopa-00000201”, “0?blacklisted”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@app-blacklist-check:2] Set(“SIP/Maricopa-00000201”, “CALLED_BLACKLIST=1”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@app-blacklist-check:3] Return(“SIP/Maricopa-00000201”, “”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:3] Set(“SIP/Maricopa-00000201”, “CDR(did)=5205687800”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:4] ExecIf(“SIP/Maricopa-00000201”, “0 ?Set(CALLERID(name)=5202332500)”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:5] Set(“SIP/Maricopa-00000201”, “CHANNEL(musicclass)=default”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:6] Set(“SIP/Maricopa-00000201”, “__MOHCLASS=default”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:7] Set(“SIP/Maricopa-00000201”, “__CALLINGPRES_SV=allowed_not_screened”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:8] Set(“SIP/Maricopa-00000201”, “CALLERPRES()=allowed_not_screened”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [5205687800@from-trunk:9] Goto(“SIP/Maricopa-00000201”, “ivr-2,s,1”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Goto (ivr-2,s,1)
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:1] Set(“SIP/Maricopa-00000201”, “TIMEOUT_LOOPCOUNT=0”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:2] Set(“SIP/Maricopa-00000201”, “INVALID_LOOPCOUNT=0”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:3] Set(“SIP/Maricopa-00000201”, “_IVR_CONTEXT_ivr-2=”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:4] Set(“SIP/Maricopa-00000201”, “_IVR_CONTEXT=ivr-2”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:5] Set(“SIP/Maricopa-00000201”, “__IVR_RETVM=”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:6] GotoIf(“SIP/Maricopa-00000201”, “0?skip”) in new stack
[2020-11-12 08:08:05] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:7] Answer(“SIP/Maricopa-00000201”, “”) in new stack
[2020-11-12 08:08:06] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:8] Wait(“SIP/Maricopa-00000201”, “1”) in new stack
[2020-11-12 08:08:07] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:9] Set(“SIP/Maricopa-00000201”, “IVR_MSG=custom/Maricopa_Attendance”) in new stack
[2020-11-12 08:08:07] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:10] Set(“SIP/Maricopa-00000201”, “TIMEOUT(digit)=3”) in new stack
[2020-11-12 08:08:07] VERBOSE[8008][C-000000e3] func_timeout.c: – Digit timeout set to 3.000
[2020-11-12 08:08:07] VERBOSE[8008][C-000000e3] pbx.c: – Executing [s@ivr-2:11] ExecIf(“SIP/Maricopa-00000201”, “1?Background(custom/Maricopa_Attendance)”) in new stack
[2020-11-12 08:08:07] VERBOSE[8008][C-000000e3] file.c: – <SIP/Maricopa-00000201> Playing ‘custom/Maricopa_Attendance.slin’ (language ‘en’)
[2020-11-12 08:08:12] VERBOSE[8011] manager.c: == Manager ‘admin’ logged on from 127.0.0.1
[2020-11-12 08:08:12] VERBOSE[8011] manager.c: == Manager ‘admin’ logged off from 127.0.0.1
[2020-11-12 08:08:16] VERBOSE[8019] manager.c: == Manager ‘admin’ logged on from 127.0.0.1


(Dave Burgess) #11

Sorry - you can’t get here from there. VOIP.MS is going to use the ‘first’ trunk that goes to your server to deliver your call. That’s why I was so non-specific about the trunks. Your first interaction, place of action, or even notice that a call is coming is when “one” of the trunks drops a call onto your inbound “pad”. From there, the calls makes its way through your Inbound Routes, eventually matching either DID or CID (or both, or neither) to pick a specific route to take into your server. How the phone company sends calls to you is entirely up to them.

Your only option would be to set up a new provider for the other DID and track it that way.


#12

Billing at VoIP.ms, or billing done by you?

If the former, that is handled by VoIP.ms as @cynjut said and you must configure your accounts there so calls to the different DIDs draw from different balances. There is absolutely nothing that can be done by Asterisk.

For the latter, chan_sip has a limitation that it can’t properly distinguish between multiple trunks registered to the same provider server. However, for most applications (including billing), you don’t care, because the number called (DID) appears in the CDRs and your billing application can use that to know who should be charged.

The pjsip driver has a “Send Line in Registration” option, on by default, that will correctly identify the incoming trunk.

Other options:

Associate the DIDs with different servers at VoIP.ms and chan_sip will properly identify the trunk.

Use unique values after the slash in the register string for each trunk. You can check for those with custom dial plan, e.g. to set the account code, then fetch the DID from the To: header and proceed with normal processing.


(Lorne Gaetz) #13

Not an answer to your question, but letting you know that the version of FreePBX you’re using is past end of life. You should have a plan in place to get on a supported version.