Outbound routes problem

Hello,

we have a FreePBX 13.0.190.12. We have an outbound route created with patterns like 03. 04. 05. for local, national and mobile calls.
Outbound route then points to a trunk towards provider.
The problem is when we delete one of this patterns, say 05. the call is still forwarded towards trunk.
Why is this happening, is it a normal behavior and how can we fix it?
Thanks in advance.

You most likely have a pattern or outbound route setup that matches all dialed numbers that’s sending calls to your trunk.

We found that FreePBX is adding 0 to the dialed number and after this searches the outbound route.
That is why only one outbound route is always chosen.
The subroutine which is doing this is

Executing [s@sub-flp-2:1] ExecIf(“SIP/172.16.6.10-000009f4”, “1?Set(TARGET_FLP_2=0322100100)”)

What is sub-flp subroutine and how can we avoid this behavior?

That should not happen. The FLP subroutines are used to implement the Dialed Number Manipulation Rules for the trunk. It is rare to require such rules, but in any case, they should be executed after Asterisk determines which trunk to use, which occurs after the Outbound Route is selected.

Do your trunks have any such rules? If so, why?

As I can see we have no such rules, please look at log highlighted. Can you explain me why 0 appears before the 577AAAAAA number?

 == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Executing [577AAAAAA@from-sip-external:1] NoOp("SIP/172.16.16.10-000009f0", "Received incoming SIP connection from unknown peer to 577AAAAAA") in new stack
    -- Executing [577AAAAAA@from-sip-external:2] Set("SIP/172.16.16.10-000009f0", "DID=577AAAAAA") in new stack
    -- Executing [577AAAAAA@from-sip-external:3] Goto("SIP/172.16.16.10-000009f0", "s,1") in new stack
    -- Goto (from-sip-external,s,1)
    -- Executing [s@from-sip-external:1] GotoIf("SIP/172.16.16.10-000009f0", "1?checklang:noanonymous") in new stack
    -- Goto (from-sip-external,s,2)
    -- Executing [s@from-sip-external:2] GotoIf("SIP/172.16.16.10-000009f0", "1?setlanguage:from-trunk,577AAAAAA,1") in new stack
    -- Goto (from-sip-external,s,3)
    -- Executing [s@from-sip-external:3] Set("SIP/172.16.16.10-000009f0", "CHANNEL(language)=en_GB") in new stack
    -- Executing [s@from-sip-external:4] Goto("SIP/172.16.16.10-000009f0", "from-trunk,577AAAAAA,1") in new stack
    -- Goto (from-trunk,577AAAAAA,1)
    -- Executing [577AAAAAA@from-trunk:1] NoOp("SIP/172.16.16.10-000009f0", "Catch-All DID Match - Found 577AAAAAA - You probably want a DID for this.") in new stack
    -- Executing [577AAAAAA@from-trunk:2] Log("SIP/172.16.16.10-000009f0", "WARNING,Friendly Scanner from 172.16.16.10") in new stack
[2023-10-10 17:52:13] WARNING[22106][C-00000551]: Ext. 577AAAAAA:2 @ from-trunk: Friendly Scanner from 172.16.16.10
    -- Executing [577AAAAAA@from-trunk:3] Set("SIP/172.16.16.10-000009f0", "__FROM_DID=577AAAAAA") in new stack
    -- Executing [577AAAAAA@from-trunk:4] Goto("SIP/172.16.16.10-000009f0", "ext-did,s,1") in new stack
    -- Goto (ext-did,s,1)
    -- Executing [s@ext-did:1] Set("SIP/172.16.16.10-000009f0", "__DIRECTION=INBOUND") in new stack
    -- Executing [s@ext-did:2] Gosub("SIP/172.16.16.10-000009f0", "app-blacklist-check,s,1()") in new stack
    -- Executing [s@app-blacklist-check:1] GotoIf("SIP/172.16.16.10-000009f0", "0?blacklisted") in new stack
    -- Executing [s@app-blacklist-check:2] Set("SIP/172.16.16.10-000009f0", "CALLED_BLACKLIST=1") in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/172.16.16.10-000009f0", "") in new stack
    -- Executing [s@ext-did:3] ExecIf("SIP/172.16.16.10-000009f0", "0?Set(__FROM_DID=s)") in new stack
    -- Executing [s@ext-did:4] Set("SIP/172.16.16.10-000009f0", "CDR(did)=577AAAAAA") in new stack
    -- Executing [s@ext-did:5] ExecIf("SIP/172.16.16.10-000009f0", "0 ?Set(CALLERID(name)=135)") in new stack
    -- Executing [s@ext-did:6] Set("SIP/172.16.16.10-000009f0", "__MOHCLASS=") in new stack
    -- Executing [s@ext-did:7] Set("SIP/172.16.16.10-000009f0", "__REVERSAL_REJECT=FALSE") in new stack
    -- Executing [s@ext-did:8] GotoIf("SIP/172.16.16.10-000009f0", "1?post-reverse-charge") in new stack
    -- Goto (ext-did,s,10)
    -- Executing [s@ext-did:10] NoOp("SIP/172.16.16.10-000009f0", "") in new stack
    -- Executing [s@ext-did:11] Set("SIP/172.16.16.10-000009f0", "__CALLINGNAMEPRES_SV=allowed_not_screened") in new stack
    -- Executing [s@ext-did:12] Set("SIP/172.16.16.10-000009f0", "__CALLINGNUMPRES_SV=allowed_not_screened") in new stack
    -- Executing [s@ext-did:13] Set("SIP/172.16.16.10-000009f0", "CALLERID(name-pres)=allowed_not_screened") in new stack
    -- Executing [s@ext-did:14] Set("SIP/172.16.16.10-000009f0", "CALLERID(num-pres)=allowed_not_screened") in new stack
    -- Executing [s@ext-did:15] NoOp("SIP/172.16.16.10-000009f0", "CallerID Entry Point") in new stack
    -- Executing [s@ext-did:16] Goto("SIP/172.16.16.10-000009f0", "ext-trunk,2,1") in new stack
    -- Goto (ext-trunk,2,1)
    -- Executing [2@ext-trunk:1] Set("SIP/172.16.16.10-000009f0", "TDIAL_STRING=SIP/Trunk-OUT") in new stack
    -- Executing [2@ext-trunk:2] Set("SIP/172.16.16.10-000009f0", "DIAL_TRUNK=2") in new stack
    -- Executing [2@ext-trunk:3] Goto("SIP/172.16.16.10-000009f0", "ext-trunk,tdial,1") in new stack
    -- Goto (ext-trunk,tdial,1)
    -- Executing [tdial@ext-trunk:1] Set("SIP/172.16.16.10-000009f0", "OUTBOUND_GROUP=OUT_2") in new stack
    -- Executing [tdial@ext-trunk:2] GotoIf("SIP/172.16.16.10-000009f0", "0?nomax") in new stack
    -- Executing [tdial@ext-trunk:3] GotoIf("SIP/172.16.16.10-000009f0", "0?hangit") in new stack
    -- Executing [tdial@ext-trunk:4] ExecIf("SIP/172.16.16.10-000009f0", "1?Set(CALLERPRES(name-pres)=allowed_not_screened)") in new stack
    -- Executing [tdial@ext-trunk:5] ExecIf("SIP/172.16.16.10-000009f0", "1?Set(CALLERPRES(num-pres)=allowed_not_screened)") in new stack
    -- Executing [tdial@ext-trunk:6] Set("SIP/172.16.16.10-000009f0", "DIAL_NUMBER=577AAAAAA") in new stack
    -- Executing [tdial@ext-trunk:7] GosubIf("SIP/172.16.16.10-000009f0", "1?sub-flp-2,s,1()") in new stack
    **-- Executing [s@sub-flp-2:1] ExecIf("SIP/172.16.16.10-000009f0", "0?Set(TARGET_FLP_2=0577AAAAAA)") in new stack**
    -- Executing [s@sub-flp-2:2] GotoIf("SIP/172.16.16.10-000009f0", "0?match") in new stack
    -- Executing [s@sub-flp-2:3] Return("SIP/172.16.16.10-000009f0", "") in new stack
    -- Executing [tdial@ext-trunk:8] Set("SIP/172.16.16.10-000009f0", "OUTNUM=577AAAAAA") in new stack
    -- Executing [tdial@ext-trunk:9] Set("SIP/172.16.16.10-000009f0", "DIAL_TRUNK_OPTIONS=T") in new stack
    -- Executing [tdial@ext-trunk:10] Dial("SIP/172.16.16.10-000009f0", "SIP/Trunk-OUT/577AAAAAA,300,T") in new stack
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Called SIP/Trunk-OUT/577AAAAAA
    -- Got SIP response 603 "Declined" back from 169.169.169.169:5060
    -- SIP/Trunk-OUT-000009f1 is busy
  == Everyone is busy/congested at this time (1:1/0/0)
    -- Executing [tdial@ext-trunk:11] Set("SIP/172.16.16.10-000009f0", "CALLERID(number)=135") in new stack
    -- Executing [tdial@ext-trunk:12] Set("SIP/172.16.16.10-000009f0", "CALLERID(name)=Di Di") in new stack
    -- Executing [tdial@ext-trunk:13] Hangup("SIP/172.16.16.10-000009f0", "") in new stack
  == Spawn extension (ext-trunk, tdial, 13) exited non-zero on 'SIP/172.16.16.10-000009f0'

It appears due to dialplan logic. It’s an ExecIf statement, if logic is true then set the dialplan variable TARGET_FLP_2 to “0577AAAAAA”. It is not true, so it isn’t set. The number actually dialed out on “Trunk-OUT” is “577AAAAAA”. That TARGET_FLP_2 does not appear to be the cause from what I can tell. Unless it needs to be set.

This call is messed up from the start – it’s not from a recognized source, but you have Allow SIP Guests and Allow Anonymous Inbound SIP Calls both on (and perhaps some other bandaids as well), so the call gets processed.

Where is this call coming from (a human on an extension, an external call arriving on a trunk, a local machine e.g. predictive dialer, something else)? Whatever the source, fix your configuration so it is recognized and processed accordingly.

Are you intentionally using chan_sip, or is the selection of that driver (rather than pjsip) part of the problem?

Once you get the above fixed, if your calls are still failing, post a new log.

Thanks for your answers.
We found that call is actually is routed by incoming route to a trunk.

The configuration is like this.
We have CUCM connected to a FreePBX. FreePBX is connected to a Provider and to a GSM Gateway.
We need calls from some extensions, created on CUCM to be routed to:

  1. GSM for mobile calls;
  2. Provider for local, national and international calls.

Calls from other CUCM extensions should be routed differently.

Now we can not route mobile calls from caller 135 to GSM Gateway.
How can we choose inbound route by CallerID?

– Executing [5XXXXXX@from-sip-external:1] NoOp(“SIP/172.16.16.10-00000a6b”, “Received incoming SIP connection from unknown peer to 5XXXXXX”) in new stack
– Executing [5XXXXXX@from-sip-external:2] Set(“SIP/172.16.16.10-00000a6b”, “DID=5XXXXXX”) in new stack
– Executing [5XXXXXX@from-sip-external:3] Goto(“SIP/172.16.16.10-00000a6b”, “s,1”) in new stack
– Goto (from-sip-external,s,1)
– Executing [s@from-sip-external:1] GotoIf(“SIP/172.16.16.10-00000a6b”, “1?checklang:noanonymous”) in new stack
– Goto (from-sip-external,s,2)
– Executing [s@from-sip-external:2] GotoIf(“SIP/172.16.16.10-00000a6b”, “1?setlanguage:from-trunk,5XXXXXX,1”) in new stack
– Goto (from-sip-external,s,3)
– Executing [s@from-sip-external:3] Set(“SIP/172.16.16.10-00000a6b”, “CHANNEL(language)=en_GB”) in new stack
– Executing [s@from-sip-external:4] Goto(“SIP/172.16.16.10-00000a6b”, “from-trunk,5XXXXXX,1”) in new stack
– Goto (from-trunk,5XXXXXX,1)
– Executing [5XXXXXX@from-trunk:1] Set(“SIP/172.16.16.10-00000a6b”, “__DIRECTION=INBOUND”) in new stack
– Executing [5XXXXXX@from-trunk:2] Set(“SIP/172.16.16.10-00000a6b”, “__FROM_DID=5XXXXXX”) in new stack
– Executing [5XXXXXX@from-trunk:3] Goto(“SIP/172.16.16.10-00000a6b”, “s,1”) in new stack
– Goto (from-trunk,s,1)
– Executing [s@from-trunk:1] Set(“SIP/172.16.16.10-00000a6b”, “__DIRECTION=INBOUND”) in new stack
– Executing [s@from-trunk:2] Gosub(“SIP/172.16.16.10-00000a6b”, “app-blacklist-check,s,1()”) in new stack
– Executing [s@app-blacklist-check:1] GotoIf(“SIP/172.16.16.10-00000a6b”, “0?blacklisted”) in new stack
– Executing [s@app-blacklist-check:2] Set(“SIP/172.16.16.10-00000a6b”, “CALLED_BLACKLIST=1”) in new stack
– Executing [s@app-blacklist-check:3] Return(“SIP/172.16.16.10-00000a6b”, “”) in new stack
– Executing [s@from-trunk:3] ExecIf(“SIP/172.16.16.10-00000a6b”, “0?Set(__FROM_DID=s)”) in new stack
– Executing [s@from-trunk:4] Set(“SIP/172.16.16.10-00000a6b”, “CDR(did)=5XXXXXX”) in new stack
– Executing [s@from-trunk:5] ExecIf(“SIP/172.16.16.10-00000a6b”, “0 ?Set(CALLERID(name)=135)”) in new stack
– Executing [s@from-trunk:6] Set(“SIP/172.16.16.10-00000a6b”, “__MOHCLASS=”) in new stack
– Executing [s@from-trunk:7] Set(“SIP/172.16.16.10-00000a6b”, “__REVERSAL_REJECT=FALSE”) in new stack
– Executing [s@from-trunk:8] GotoIf(“SIP/172.16.16.10-00000a6b”, “1?post-reverse-charge”) in new stack
– Goto (from-trunk,s,10)
– Executing [s@from-trunk:10] NoOp(“SIP/172.16.16.10-00000a6b”, “”) in new stack
– Executing [s@from-trunk:11] Set(“SIP/172.16.16.10-00000a6b”, “__CALLINGNAMEPRES_SV=allowed_not_screened”) in new stack
– Executing [s@from-trunk:12] Set(“SIP/172.16.16.10-00000a6b”, “__CALLINGNUMPRES_SV=allowed_not_screened”) in new stack
– Executing [s@from-trunk:13] Set(“SIP/172.16.16.10-00000a6b”, “CALLERID(name-pres)=allowed_not_screened”) in new stack
– Executing [s@from-trunk:14] Set(“SIP/172.16.16.10-00000a6b”, “CALLERID(num-pres)=allowed_not_screened”) in new stack
– Executing [s@from-trunk:15] NoOp(“SIP/172.16.16.10-00000a6b”, “CallerID Entry Point”) in new stack
– Executing [s@from-trunk:16] Goto(“SIP/172.16.16.10-00000a6b”, “ext-trunk,2,1”) in new stack
– Goto (ext-trunk,2,1)
– Executing [2@ext-trunk:1] Set(“SIP/172.16.16.10-00000a6b”, “TDIAL_STRING=SIP/Route-OUT”) in new stack
– Executing [2@ext-trunk:2] Set(“SIP/172.16.16.10-00000a6b”, “DIAL_TRUNK=2”) in new stack
– Executing [2@ext-trunk:3] Goto(“SIP/172.16.16.10-00000a6b”, “ext-trunk,tdial,1”) in new stack
– Goto (ext-trunk,tdial,1)
– Executing [tdial@ext-trunk:1] Set(“SIP/172.16.16.10-00000a6b”, “OUTBOUND_GROUP=OUT_2”) in new stack
– Executing [tdial@ext-trunk:2] GotoIf(“SIP/172.16.16.10-00000a6b”, “0?nomax”) in new stack
– Executing [tdial@ext-trunk:3] GotoIf(“SIP/172.16.16.10-00000a6b”, “0?hangit”) in new stack
– Executing [tdial@ext-trunk:4] ExecIf(“SIP/172.16.16.10-00000a6b”, “1?Set(CALLERPRES(name-pres)=allowed_not_screened)”) in new stack
– Executing [tdial@ext-trunk:5] ExecIf(“SIP/172.16.16.10-00000a6b”, “1?Set(CALLERPRES(num-pres)=allowed_not_screened)”) in new stack
– Executing [tdial@ext-trunk:6] Set(“SIP/172.16.16.10-00000a6b”, “DIAL_NUMBER=5XXXXXX”) in new stack
– Executing [tdial@ext-trunk:7] GosubIf(“SIP/172.16.16.10-00000a6b”, “1?sub-flp-2,s,1()”) in new stack
– Executing [s@sub-flp-2:1] ExecIf(“SIP/172.16.16.10-00000a6b”, “0?Set(TARGET_FLP_2=05XXXXXX)”) in new stack
– Executing [s@sub-flp-2:2] GotoIf(“SIP/172.16.16.10-00000a6b”, “0?match”) in new stack
– Executing [s@sub-flp-2:3] Return(“SIP/172.16.16.10-00000a6b”, “”) in new stack
– Executing [tdial@ext-trunk:8] Set(“SIP/172.16.16.10-00000a6b”, “OUTNUM=5XXXXXX”) in new stack
– Executing [tdial@ext-trunk:9] Set(“SIP/172.16.16.10-00000a6b”, “DIAL_TRUNK_OPTIONS=T”) in new stack
– Executing [tdial@ext-trunk:10] Dial(“SIP/172.16.16.10-00000a6b”, “SIP/Route-OUT/5XXXXXX,300,T”) in new stack
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Called SIP/Route-OUT/5XXXXXX
– Got SIP response 603 “Declined” back from 169.169.169.169:5060
– SIP/Route-OUT-00000a6c is busy
== Everyone is busy/congested at this time (1:1/0/0)
– Executing [tdial@ext-trunk:11] Set(“SIP/172.16.16.10-00000a6b”, “CALLERID(number)=135”) in new stack
– Executing [tdial@ext-trunk:12] Set(“SIP/172.16.16.10-00000a6b”, “CALLERID(name)=Di Di”) in new stack
– Executing [tdial@ext-trunk:13] Hangup(“SIP/172.16.16.10-00000a6b”, “”) in new stack
== Spawn extension (ext-trunk, tdial, 13) exited non-zero on ‘SIP/172.16.16.10-00000a6b’

I checked CID Priority Route and now it works.

But now the question is that we need this inbound route to work for a number of callerIDs. So we need to create an inbound route for each of them or could we create one inbound route and put all needed CallerIDs inside it. Is it possible?

If the numbers to be treated specially are in a block, you can use a pattern, e.g. 2XX will match 200 through 299.

However, IMO the basic setup is wrong. The trunk from CUCM should be correctly identified, but it is not. Check the peer details and confirm that the host= and port= parameters match the IP address and port from which CUCM is sending the calls. Then, set context=from-internal for this trunk, and calls into the trunk will use Outbound Routes.

We already have this configuration on the trunk connecting to CUCM, but is does not work as explained.

And also we tried to use pattern such as 13[5] for testing on inbound route but it does not work.

Any ideas please?

And one more qustion, is there any good manual or book about how to create FreePBX infrastructure and connections?

Thank you very much, all this time I was digging in theory, as at first I even did not understand what you told to me. Now I see it was very helpful. You are absolutely right, call from CUCM is coming from random port and therefore is falling inside from-sip-external context.

Now we need to change scheme of our calling infrastructure.

One question is how to force CUCM send invites from single port 5060 for example?

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