This Article is describe how you can configure Failover Dialplan for you Asterisk Server. for this need some steps to follow.
Step # 1
In step on need to register Number of SIP Trunks you want to use in Failover routing in our case we are using 3 SIP Trunks for Failover.
vi /etc/asterisk/sip.conf
[SIP1]
type=peer
host=XXX.XXX.XXX.XXX
username=XXX.XXX
type=peer
host=XXX.XXX.XXX.XXX
username=XXX.XXX
fromuser=XXX.XXX
secret=XXX.XXX
canreinvite=no
secret=XXX.XXX
canreinvite=no
[SIP2]
type=peer
host=XXX.XXX.XXX.XXX
username=XXX.XXX
type=peer
host=XXX.XXX.XXX.XXX
username=XXX.XXX
fromuser=XXX.XXX
secret=XXX.XXX
canreinvite=no
secret=XXX.XXX
canreinvite=no
[SIP3]
type=peer
host=XXX.XXX.XXX.XXX
username=XXX.XXX
type=peer
host=XXX.XXX.XXX.XXX
username=XXX.XXX
fromuser=XXX.XXX
secret=XXX.XXX
canreinvite=no
secret=XXX.XXX
canreinvite=no
Step 2
vi /etc/asterisk/extensions.conf
exten => _X.,n,GotoIf($[“${DIALSTATUS}”=”CHANUNAVAIL”|”${DIALSTATUS}”=”CONGESTION”|”${DIALSTATUS}”=”CANCEL”|”${DIALSTTUS}”=”automon”|”${DIALSTATUS}”=”NOANSWER”|”${HANGUPCAUSE}”=”0″|”${HANGUPCAUSE}”=”34”]?failover)
exten => _X.,n(failover),Dial(SIP/${EXTEN:2}@SIP1,,tTo))
exten => _X.,n(failover),Dial(SIP/${EXTEN:2}@SIP1,,tTo))
exten => _X.,n,GotoIf($[“${DIALSTATUS}”=”CHANUNAVAIL”|”${DIALSTATUS}”=”CONGESTION”|”${DIALSTATUS}”=”CANCEL”|”${DIALSTTUS}”=”automon”|”${DIALSTATUS}”=”NOANSWER”|”${HANGUPCAUSE}”=”0″|”${HANGUPCAUSE}”=”34”]?failover)
exten => _X.,n(failover),Dial(SIP/${EXTEN:2}@SIP2,,tTo))
exten => _X.,n,GotoIf($[“${DIALSTATUS}”=”CHANUNAVAIL”|”${DIALSTATUS}”=”CONGESTION”|”${DIALSTATUS}”=”CANCEL”|”${DIALSTATUS}”=”NOANSWER”|”${DIALSTATUS}”=”automon”|”${HANGUPCAUSE}”=”0″|”${HANGUPCAUSE}”=”34”]?failover2)
exten => _X.,n(failover2),Dial(SIP/${EXTEN:1}@SIP3,,tTo)
exten => _X.,n,Hangup
exten => _X.,n(failover),Dial(SIP/${EXTEN:2}@SIP2,,tTo))
exten => _X.,n,GotoIf($[“${DIALSTATUS}”=”CHANUNAVAIL”|”${DIALSTATUS}”=”CONGESTION”|”${DIALSTATUS}”=”CANCEL”|”${DIALSTATUS}”=”NOANSWER”|”${DIALSTATUS}”=”automon”|”${HANGUPCAUSE}”=”0″|”${HANGUPCAUSE}”=”34”]?failover2)
exten => _X.,n(failover2),Dial(SIP/${EXTEN:1}@SIP3,,tTo)
exten => _X.,n,Hangup
Press esc then :
wq
reload your asterisk and you have done…..!!!!!
Reblogged this on Global-hardware.
hello,
I’ve 1500 different provider SIP trunk. any idea about dial plan?
i want to dial without create 1500 dial plan
The main thing how you wish to distribute the traffic among provider do you wish to setup failover ? or simple routing.
you can make a context where you can define your all trunks as failover and can route all calls to that context simple is that 🙂