Asterisk connects with FXO gateway

The network environment is:

Asterisk connects to the public Internet directly;  Gateway is behind the router in the LAN.

The purpose is:

If all the extensions dial 0+any number, the call will go out through FXO 1 of gateway;

If all the extensions dial 1-9+any number, the call will go out through FXO 2 of gateway.

Any calls from gateway will be transferred to asterisk, and we will hear the IVR.

 

The detailed steps are:

Firstly, let us configure the asterisk.

1. Create an account (lesheng801) for extension and create another account(lesheng-trunk1) for IP trunk. Please enter the following content in the file sip.conf.

[general]

match_auth_username=yes

[lesheng801]

type=friend

context=lesheng

host=dynamic

nat=yes

secret=voptech1984

dtmfmode=auto

disallow=all

allow=ulaw

allow=alaw

allow=gsm

qualify=yes

directmedia=no

[lesheng-trunk1]

context=fxo-trunk

type=friend

host=dynamic

nat=yes

dtmfmode=auto

disallow=all

allow=ulaw

allow=alaw

allow=gsm

qualify=yes

directmedia=no

secret=voptech1984

2. Make a dial plan. Please enter the following content in the file extensions.conf.
exten => _X.,1,Dial(SIP/lesheng-trunk1/${EXTEN})
It means when the extension lesheng801 dials any number, the call will be transferred to the server which lesheng-trunk1 registers to.

[lesheng]

exten => _X.,1,Dial(SIP/lesheng-trunk1/${EXTEN})

[fxo-trunk]

;when you dial 200, you will hear an IVR(conf-usermenu). If you dial 1 during the IVR or you dial 1 in 5 seconds after IVR is over, the extension lesheng801 will ring.

exten => 200,1,Answer()

same => n,Background(conf-usermenu)

same => n,WaitExten(5)

exten => 1,1,Dial(SIP/lesheng801,10)

same => n,Playback(vm-nobodyavail)

same => n,Hangup()

;if you press any other keys besides 1, you will hear a voice(pbx-invalid), and go back to the start.

exten => i,1,Playback(pbx-invalid)

same => n,Goto(fxo-trunk,200,1)

;if you donot press any keys, you will hear a voice(goodbye).

exten => t,1,Playback(vm-goodbye)

same => n,Hangup()

Secondly, let us configure the gateway.

1. Register to asterisk, and please go to Basic->SIP, here v.voptech.com is the address of asterisk.

1

2. Please enter the account in trunk 1 and trunk 2.

2

3

Binding number 200 means: When any users from outside call in through FXO 1-2, they will hear an IVR.

3. Please write the routing.

4

IP   0X.   ROUTE   FXO   1

It means any calls starting with 0 from any IP will be routed to the FXO 1.

IP   [1-9]X.    ROUTE   FXO   2

It means any calls starting with 1-9 from any IP will be routed to the FXO 2.

No comments yet.

Leave a Reply