Question regarding extensions.conf and dialplan

Good afternoon Everyone,

as I am able with the kind help of jcolp to receive any calls from the provider lines I still have problems with outbound calls.
I’d like to achieve that certain internal endpoints using a specific outbound line.
For example:

  • internal endpoints 10, 13, 14, 15, 20, 27 must use line 1
  • internal enpoints 11, 21 must use line 2
  • internal endponts 21, 29 must use line 3
  • internal endpoint 12 must use line 4
  • internal endpoint 13 must use line 5

All internal endpoints are defined and can connect each other.
All internal endpoints mentioned above can be reached via the respective lines

I have no idea how the extensions.conf must look like in order to achieve the dialplan mentioned above.

I’m thankful for any hint.

Best regards,


It would be easy enough to define 5 different contexts in your extensions.conf and put the phones you want in each context.

include => internal-phones
exten => _X.,1,Dial(PJSIP/${EXTEN}@line1)

include => internal-phones
exten => _X.,1,Dial(PJSIP/${EXTEN}@line2)

 exten => _[12X],1,Dial(PJSIP/${EXTEN})

in your pjsip.conf define some templates and apply them to your endpoints

context = internal-line1

context = internal-line2






Worked perfectly!

Good evening John,

unfortunately I was too early with my message.

The outbound calls are distributed exactly as I want them to be.
But the include statement in my extensions.conf isn’t working.


exten => 10,1,Dial(SCCP/10)
exten => 11,1,Dial(SCCP/11)
exten => 12,1,Dial(SCCP/12)
exten => 20,1,Dial(PJSIP/20)
exten => 21,1,Dial(PJSIP/21)
exten => 22,1,Dial(PJSIP/22)
exten => 23,1,Dial(PJSIP/23)

include => internal

;natinal, leading +49
exten => _+49X.,1,Dial(PJSIP/Telekom_01_out/sip:0${EXTEN:3},60)
exten => _+49X.,n,Hangup()

;no international call
exten => _+X.,1,Hangup()
exten => _00X.,1,Hangup()

;national, leading 0
exten => _0Z.,1,Dial(PJSIP/Telekom_01_out/sip:${EXTEN},60)
exten => _0Z.,n,Hangup()

; local
exten => _Z.,1,Dial(PJSIP/Telekom_01_out/sip:02252${EXTEN},60)
exten => _Z.,n,Hangup()

include => internal

include => internal

Note: the respective context fo the SCCP extensions is configured, outbound calls are working like SIP endpoints.

If I dial a two digit number from any extension it won’t use the internal context but e.g.context Telekom_01_out. Of course this won’t work.

Where do I made the mistake??

Try a ‘dialplan show 10@Telekom_01_out’

Is it matching the pattern match before the include?

Can you be more specific with your pattern match for local calls to avoid a collision?

Matching order is that of the current context and then includes are queried (in order). A context which simply includes other contexts would give absolute control.

AsteriskPi*CLI> dialplan show 10@Telekom_01_out
[ Context ‘Telekom_01_out’ created by ‘pbx_config’ ]
’_Z.’ => 1. Dial(PJSIP/Telekom_01_out/sip:02252${EXTEN},60) [pbx_config]
2. Hangup() [pbx_config]
[ Included context ‘internal’ created by ‘pbx_config’ ]
‘10’ => 1. Dial(SCCP/10) [pbx_config]

The context in which the others context are included needs to be addresses by pjsip.conf.
The other (included) contexts are free, do I understand this right?

If I’m understanding your question, yes.

I’m sure you do :slight_smile:
If not I’m the one who’s not able to ask a question well understandable…


You guys are great and very kind to newbies!

OK so yeah that’s your problem right there, because the included extension is showing up below your pattern match it won’t get the call.

You could solve this by using multiple contexts and including them in the order you wish them to match.

Remove your include from inside the ‘Telekom_01_out’ context

Create a new context and include both your internal and your Telekom_01_out context inside it.

include => internal
include => Telekom_01_out

Then reconfigure your endpoint(s) to use the newly defined context.

It worked.

Thanks for the help!

1 Like