Specifying a trunk for an extension to use

I’m working on an asterisk 1.4.16.2 and freepbx machine. The goal is to have multiple phone numbers on a single pbx, instead of a pbx for each number. The problem is with outgoing calls. I have set up custom contexts for each extension, but it always seems to use the first trunk instead of the one which should be associated with that extension. Below is one of the extensions, along with the context and outbound trunk list.

[220]
type=friend
secret=****
record_out=Adhoc
record_in=Adhoc
qualify=yes
port=5060
pickupgroup=
nat=yes
mailbox=220@default
host=dynamic
dtmfmode=rfc2833
disallow=
dial=SIP/220
context=custom_mms
canreinvite=no
callgroup=
callerid=device <220>
allow=
accountcode=
call-limit=50
[custom_dce] ; 201-209
include => parkedcalls
include => from-internal
include => ext-fax
include => from-internal-additional
exten => s,1,Macro(hangupcall)
exten => h,1,Macro(hangupcall)
exten => _NXX,DIAL(SIP/DCE_out/${EXTEN}|120|W)
exten => _NXXXXXX,DIAL(SIP/DCE_out/${EXTEN}|120|W)
exten => _1NXXNXXXXXX,DIAL(SIP/DCE_out/${EXTEN}|120|W)

[custom_foster] ; 210-219
include => parkedcalls
include => from-internal
include => ext-fax
include => from-internal-additional
exten => s,1,Macro(hangupcall)
exten => h,1,Macro(hangupcall)
exten => _NXX,DIAL(SIP/Foster_out/${EXTEN}|120|W)
exten => _NXXXXXX,DIAL(SIP/Foster_out/${EXTEN}|120|W)
exten => _1NXXNXXXXXX,DIAL(SIP/Foster_out/${EXTEN}|120|W)

[custom_mms] ; 220-229
include => parkedcalls
include => from-internal
include => ext-fax
include => from-internal-additional
exten => s,1,Macro(hangupcall)
exten => h,1,Macro(hangupcall)
exten => _NXX,DIAL(SIP/MMS_out/${EXTEN}|120|W)
exten => _NXXXXXX,DIAL(SIP/MMS_out/${EXTEN}|120|W)
exten => _1NXXNXXXXXX,DIAL(SIP/MMS_out/${EXTEN}|120|W)
[DCE_out]
username=****
type=peer
insecure=very
host=xxxx
fromuser=****
fromdomain=xxxx
canreinvite=no
call-limit=50

[Foster_out]
username=****
type=peer
insecure=very
host=xxxx
fromuser=****
fromdomain=xxxx
canreinvite=no
call-limit=50

[MMS_out]
username=****
type=peer
insecure=very
host=xxxx
fromuser=****
fromdomain=xxxx
canreinvite=no
call-limit=50

Am I missing something in there? Or how can I figure out why it always seems to use DCE_out regardless of which extension is doing the calling.

Hi,

include in the custom context for the extensions only the admitted outgoing context so they can use only that.

cheers
smaikol

I’m afraid I don’t follow you. I’m not very good at manually configuring asterisk yet. This configuration was previously created by someone else. Can you clarify what needs doing?

Try to comment from-internal adn from-internal-additional
See if it still do a wrong dial out.

The alternative is to create a from-internal-custom
If you look at from-internal it includes all the outgoing trunk, in the custom take away the outgoing you don’t want to use and assign the cutom to the peer.

cheers
smaikol

Thank you, this was very helpful. :smile:

I copied from-internal-additional to from-internal-custom, and removed the “include => outbound-allroutes”. In each custom context, I now only include from-internal-custom and the appropriate outrt macro. And now it’s calling out on the correct trunk for each extension.