PSTN ZAP Trunk

Hello Experts,

I have a question regarding on pstn incoming calls. I have Digium TDM card installed on the pc with 4 FXO. Each FXO channels are terminated with our 4 PSTN lines. I want all channels can received calls and at the same time can calls outside. I have set a dial plan below, kindly check if i did right. I can received incoming calls and ring it to the extension assigned but it does not work for outside calling and extension to extension calling.

Please show me what is the correct way. Thanks…

zapata.conf

[trunkgroups]



; FXO 1
signalling=fxs_ks
context=incoming1
group=1
channel=>1

; FXO 2
signalling=fxs_ks
context=incoming2
group=1
channel=>2

; FXO 3
signalling=fxs_ks
context=incoming3
group=1
channel=>3

; FXO 4
signalling=fxs_ks
context=incoming4
group=1
channel=>4

=========================================================

[general]
static=yes
writeprotect=no

[globals]
CONSOLE=Console/dsp
TRUNK=Zap/g1
TRUNKMSD=1

; Outbound
exten => _9xxxxxxx,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})

include => incoming1
include => incoming2
include => incoming3
include => incoming4

; Inbound
[incoming1]
exten => s,1,Ringing()
exten => s,2,Answer()
exten => s,3,Dial(Sip/2001|10)
exten => s,4,Hangup

[incoming2]
exten => s,1,Ringing()
exten => s,2,Answer()
exten => s,3,Dial(Sip/2001|10)
exten => s,4,Hangup

[incoming3]0
exten => s,1,Ringing()
exten => s,2,Answer()
exten => s,3,Dial(Sip/2003|10)
exten => s,4,Hangup

[incoming4]
exten => s,1,Ringing()
exten => s,2,Answer()
exten => s,3,Dial(Sip/2004|10)
exten => s,4,Hangup

[default]
exten => 2001,1,Dial(Sip/2001|10)
exten => 2001,2,Hangup

exten => 2002,1,Dial(Sip/2002|10)
exten => 2002,2,Hangup

exten => 2003,1,Dial(Sip/2003|10)
exten => 2003,2,Hangup

exten => 2004,1,Dial(Sip/2004|10)
exten =>2004,2,Hangup

Is there a way that I can assign instead of s a zap channel i would set like ZAP/1 for FXO1, ZAP/2 for FXO2, ZAP/3 for FXO3 and ZAP/4 for FXO4…

Thanks in advanced for your help…

Sure.

First. Since you have all the lines going to the same context why not do this:

zaptel.conf

zapata.conf

[trunkgroups]
...
...
..
..

; ALL FXO
signalling=fxs_ks
context=pstn-incoming
group=1
channel=>1-4

Then all you need is one context in extensions.conf for incoming.

extensions.conf


[general]
static=yes
writeprotect=no

[globals]
CONSOLE=Console/dsp
TRUNK=Zap/g1
TRUNKMSD=1




; Inbound
[pstn-incoming]
exten => s,1,Ringing()
exten => s,2,Answer()
exten => s,3,Dial(Sip/2001|10)
exten => s,4,Hangup

[default]
exten => 2001,1,Dial(Sip/2001|10)
exten => 2001,2,Hangup

exten => 2002,1,Dial(Sip/2002|10)
exten => 2002,2,Hangup

exten => 2003,1,Dial(Sip/2003|10)
exten => 2003,2,Hangup

exten => 2004,1,Dial(Sip/2004|10)
exten =>2004,2,Hangup

[internal]

; Outbound
exten => _9xxxxxxx,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})

Also notice how I set your outgoing calls to a context called internal. You don’t want people from the outside to make calls for free on your system.

Since you have group=1 in zapata.conf all you need to dial out is:

Exten => _9xxxxxxx,1,Dial(ZAP/g1/${EXTEN})

Note the g1. This tells asterisk to dial out on group 1 which we set to all four lines. Asterisk will try the first available line.