Help Staying in the Default Extensions on an Internal Call!

On an internal call, DID to local DID, we have the following dial plan ( the x’s represent numbers that we have)

exten => _407xxxxxx,1,noop(${EXTEN})
same => n,GotoIf($[$[${EXTEN} > xxxxxxxxxx & $[ ${EXTEN} < xxxxxxxxxx]]?internalCall)
same => n,dial(sip/SwwitchVox 1/${EXTEN})
same => n, Hangup()
;same => n,dial(sip/${EXTEN})
same => n(internalCall), dial(sip/${EXTEN})
same => n, Hangup()

this is set so that if we have a call that should stay internal it does and anything else it pushes out the switchvox sip trunk. This works.

THE ISSUE: If an internal call is made and the extension is internally based on the above dial plan, it dials the extension as it is. So if a ten digit number comes in that 10 digit number is dialed without regard to the actual exten=>
However, the extension that we need to call is in the extension file as you see below. Which is a 10 digit number being sent to another server through a sip trunk

exten => 3212223333,1,Dial(SIP/99001@GA)

So what I am looking to have it do is if the call is internal, dial the extension in the file exten=>

Thanks for your help.


You would need to create a separate context and direct internal stuff to there, or include such contexts in this one.

The context is included in this one, but I feel like the Dial on the end is telling it to do exactly that instead of fine the extension and then dial it from there.

BTW awesome hat…

If you provide the console output of an attempt then we can see exactly what it is doing. The dialplan doesn’t work like you’re describing, so it’s something else or it’s not dialing like you assume.

Thanks! It’s a white top hat.

This is what I am seeing. The called number is not registered on this server as you can se

== Using SIP RTP CoS mark 5
– Executing [4074046456@default:1] NoOp(“SIP/4074046455-00001812”, “4074046456”) in new stack
– Executing [4074046456@default:2] GotoIf(“SIP/4074046455-00001812”, “1?internalCall”) in new stack
– Goto (default,4074046456,5)
– Executing [4074046456@default:5] Dial(“SIP/4074046455-00001812”, “sip/4074046456”) in new stack
[2016-04-21 11:57:13] WARNING[8896]: chan_sip.c:5818 create_addr: Purely numeric hostname (4074046456), and not a peer–rejecting!
[2016-04-21 11:57:13] WARNING[8896]: app_dial.c:2345 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)
– Executing [4074046456@default:6] Hangup(“SIP/4074046455-00001812”, “”) in new stack
== Spawn extension (default, 4074046456, 6) exited non-zero on ‘SIP/4074046455-00001812’

Do you need to strip digits from the front? If so you can use ${EXTEN:n} where n is how many to strip. For example: ${EXTEN:6} to strip the first 6 digits. So:

same => n(internalCall), dial(sip/${EXTEN:6})

No, in this sample we are not stripping out numbers.


I don’t understand what you are attempting to do then. The dialed number is “4074046456”. Your dialplan is written to then try to dial SIP/4074046456 in this case and it’s not working. The dialplan is doing exactly as you’ve told it to do.

Correct and that is the issue,

I I dial SIP/4074046456 what I want it to do is to dial

exten => 4074046456,1,Dial(SIP/99001@GA) so that it goes to a sip trunk to another server. but when it goes through

exten => _407xxxxxx,1,noop(${EXTEN})
same => n,GotoIf($[$[${EXTEN} > xxxxxxxxxx & $[ ${EXTEN} < xxxxxxxxxx]]?internalCall)
same => n,dial(sip/SwwitchVox 1/${EXTEN})
same => n, Hangup()
;same => n,dial(sip/${EXTEN})
same => n(internalCall), dial(sip/${EXTEN})
same => n, Hangup()

and it determines that it is a local call it

same => n(internalCall), dial(sip/${EXTEN})

and dials the number instead of going to the internal extension of

exten => 4074046456,1,Dial(SIP/99001@GA)

to go through the sip trunk, and the call fails miserably.


What is the complete dialplan logic? Is the explicit match actually in the context?

You have mis-matched square brackets and too many of them; you only need one level here.

Normally one would use pattern match syntax for this.

Using literal x’s as well as meta ones is confusing

I’m sorry for the x’s.

There is an exact match in the context

The _ is unnecessary, but not relevant to the problem. (I didn’t think that x matched, only X, but I could see why you obfuscated the dialplan when the trace shows the actual number.)

It dials the number because you are telling to Asterisk to dial a sip extension. Asterisk then lookups what it has as a sip extenion, it doesn’t find anything because there isn’t any sip extension with this number. Not finding a sip extension, Asterisk decides that this is then a sip trunk and dial what it sees but dialing this string is not right becuase dialing a straight sip address should be like this sip/host/extension and returns an error saying that the host doesn’t exist.

What you should do is use the Local channel to jump to the extension that you want.
So the dial string should be like this

same => n(internalCall),dial(Local/${EXTEN}@my-context)

You should change my-context to the name of your context.
Also bare in mind that the pattern that you have _407xxxxxx might match with exten => 4074046456,1,Dial(SIP/99001@GA). If you want to keep this dialplan you should do something for that or consider changing your dialplan logic.