Forwarding calls to specific exten

Hello,
I’m a newbie on this forum and I have a few questions. I have 8 extensions (spa941) and 2 voip gateway modules (SPA-3102) and the problem is that I can’t make specific modules to forward calls on specific extensions. I need to forward calls from spa3102-1 only to linksys941-1 and linksys941-4. What I have now is case in which calls from both modules (3012-1 and 3012-2) are forwarded to linksys941-6 and linksys941-3. Here is my extensions.conf file and I would appreciate if someone would take a look and try to figure it out:

[i][zivinice_mediasky]

exten => _[235678]XXXXX,1,Set(TIMEOUT(absolute)=600)
exten => _[235678]XXXXX,1,Dial(SIP/spa3102-2/${EXTEN})
exten => _[235678]XXXXX,2,Dial(SIP/spa3102-1/${EXTEN})
exten => _[235678]XXXXX,n,HangUp()

exten => _12X,1,Set(TIMEOUT(absolute)=600)
exten => _12X,1,Dial(SIP/spa3102-2/${EXTEN})
exten => _12X,2,Dial(SIP/spa3102-1/${EXTEN})
exten => _12X,n,HangUp()

[adm_ba_over_pstn_mediasky]
exten => _0[3-5]XXXXXXX,1,Set(TIMEOUT(absolute)=600)
exten => _0[3-5]XXXXXXX,1,Dial(SIP/spa3102-2/${EXTEN})
exten => _0[3-5]XXXXXXX,2,Dial(SIP/spa3102-1/${EXTEN})
exten => _0[3-5]XXXXXXX,n,HangUp()

[adm_gsm_over_gsm_and_pstn_mediasky]
exten => _06[12356]XXXXXX,1,Set(TIMEOUT(absolute)=600)
exten => _06[12356]XXXXXX,1,Dial(SIP/spa3102-2/${EXTEN})
exten => _06[12356]XXXXXX,2,Dial(SIP/spa3102-1/${EXTEN})
exten => _06[12356]XXXXXX,n,HangUp()

[inter_over_pstn]

exten => _00X.,1,Dial(SIP/spa3102-2/${EXTEN})
exten => _00X.,2,Dial(SIP/spa3102-1/${EXTEN})
exten => _00X.,n,HangUp()

[mediasky_incoming]
exten => s,1,Dial(SIP/linksys941-6&SIP/linksys941-3,tT)
exten => s,2,Dial(SIP/linksys941-1&SIP/linksys941-4,tT)
exten => s,n,HangUp()

exten => 2400,1,Dial(SIP/linksys941-6&SIP/linksys941-3,tT)
exten => 2400,2,Dial(SIP/linksys941-1&SIP/linksys941-4,tT)
exten => 2400,n,HangUp()

[mediasky_i]
exten => s,1,HangUp()

exten => 2500,1,HangUp()

[mediasky_inc]
exten => s,1,Dial(SIP/linksys941-6&SIP/linksys941-3,tT)
exten => s,2,Dial(SIP/linksys941-1&SIP/linksys941-4,tT)
exten => s,n,HangUp()

exten => 2400,1,Dial(SIP/linksys941-6&SIP/linksys941-3,tT)
exten => 2400,2,Dial(SIP/linksys941-1&SIP/linksys941-4,tT)
exten => 2400,n,HangUp()

[mediasky_local]
exten => 402,1,Dial(SIP/linksys941-6,10,tT)
exten => 402,n,HangUp()

exten => 403,1,Dial(SIP/linksys941-3,10,tT)
exten => 403,n,HangUp()

exten => 404,1,Dial(SIP/linksys941-1,10,tT)
exten => 404,n,HangUp()

exten => 405,1,Dial(SIP/linksys941-4,10,tT)
exten => 405,n,HangUp()

exten => 406,1,Dial(SIP/linksys941-7,10,tT)
exten => 406,n,HangUp()

exten => 407,1,Dial(SIP/linksys941-8,10,tT)
exten => 407,n,HangUp()

[mediasky_all]
include => mediasky_local
include => adm_ba_over_pstn_mediasky
include => adm_gsm_over_gsm_and_pstn_mediasky
include => inter_over_pstn
include => zivinice_mediasky[/i]

You would generally use contexts for this. You will have to provide your channel driver configuration to see why you aren’t getting different contexts, and to make the dialplan easier to understand.

OK, let’s make the dial plan easier to understand. This extensions.conf file does the following:

  • both voip modules (SPA-3102 -1 and 3012-2) transfer incoming calls on all 4 extensions that will be used for incoming calls (linksys941-6, linksys941-3, linksys941-4, linksys941-1)
  • but I want the voip module 3012-2 to transfer incoming calls to (linksys941-6, linksys941-3) and other module 3012-1 to transfer calls to (linksys941-4 and linksys941-1).

I’m newbie with asterisk so I don’t know what do you mean by “channel driver configuration”

chan_dahdi.conf, sip.conf, iax.conf, etc., etc., as appropriate.

I don’t know what channel technology your trunk drivers use.

sip.conf:
[i][spa3102-1]
type = friend
username = spa3102-1
secret = xxxxx
context = mediasky_incoming
nat = yes
canreinvite = no
dtmfmode = info
qualify=yes
disallow = all
allow = ulaw
host = dynamic
call-limit = 1

[spa3102-2]
type = friend
username = spa3102-2
secret = xxxxx
context = mediasky_incoming
nat = yes
canreinvite = no
dtmfmode = info
qualify=yes
disallow = all
allow = ulaw
host = dynamic
call-limit = 1

[linksys941-6]
type = friend
username = linksys941-6
secret =xxxxx
context = mediasky_all
nat = yes
canreinvite = no
dtmfmode = info
qualify=yes
disallow = all
allow = alaw
allow = ulaw
host = dynamic
callerid = "xxxxx " <402>

[linksys941-3]
type = friend
username = linksys941-3
secret = xxxxx
context = mediasky_all
nat = yes
canreinvite = no
dtmfmode = info
qualify=yes
disallow = all
allow = alaw
allow = ulaw
host = dynamic
callerid = "xxxxx " <403>

[linksys941-1]
type = friend
username = linksys941-1
secret = xxxxx
context = mediasky_all
nat = yes
canreinvite = no
dtmfmode = info
qualify=yes
disallow = all
allow = alaw
allow = ulaw
host = dynamic
callerid = "xxxxx " <404>

[linksys941-4]
type = friend
username = linksys941-4
secret =xxxxx
context = mediasky_all
nat = yes
canreinvite = no
dtmfmode = info
qualify=yes
disallow = all
allow = alaw
allow = ulaw
host = dynamic
callerid = xxxxx " <405>

[linksys941-7]
type = friend
username = linksys941-7
secret = xxxxx
context = mediasky_all
nat = yes
canreinvite = no
dtmfmode = info
qualify=yes
disallow = all
allow = alaw
allow = ulaw
host = dynamic
callerid = "xxxxx " <406>

[linksys941-8]
type = friend
username = linksys941-8
secret =xxxxx
context = mediasky_all
nat = yes
canreinvite = no
dtmfmode = info
qualify=yes
disallow = all
allow = alaw
allow = ulaw
host = dynamic
callerid = "xxxxx " <407>
[/i]

All other config files are as default, not modified.

These should be different “context = mediasky_incoming”.

Also, type=friend is less secure than type=peer, and canrenivite is an obsolete name for directmedia. Finally, I doubt that this is a case that needs nat=yes, which applies to cases where Asterisk has the public address.