How to setup failover for multiple SIP Trunks from ITSP?

General discussions about Asterisk.

Moderators: Moderator, Support

How to setup failover for multiple SIP Trunks from ITSP?

Postby dev_shah » Wed Aug 08, 2012 8:21 am

I have two SIP Trunks(from ITSP) coming into two Asterisk servers at different physical location.

Note: ITSP stands for Internet Telephony Service Provider
Inbound call stands for call coming from ITSP to Asterisk
Outboud call stands for call from Asterisk to ITSP
ServerA and ServerB stands for Asterisk server at location A and B.


Inbound call is not an issue. ITSP is smart to send call to us in Round Robin fashion (first incoming call on serverA and second incoming call on serverB). If serverA dies, incoming call comes only to serverB. ITSP periodically pings serverA and serverB. If ITSP sees that serverA is alive, ITSP starts sending call to serverA. [Note: No manual intervention involved here]

I would like to achieve something similar to above in Asterisk. I would like to setup serverA such that it will send calls to TrunkA and TrunkB in Round Robin fashion(first call to TrunkA and second call to TrunkB). If TrunkA fails, it shouldn't send the call to TrunkA. I also want Asterisk to periodically ping TrunkA to check if trunk is alive or not. Once TrunkA is alive, it should start sending call to it.

I am wondering if you guys came across this issue. It would be great if you can provide any resources or assistance.
dev_shah
Newsterisk
 
Posts: 5
Joined: Tue Jan 25, 2011 9:13 am

Re: How to setup failover for multiple SIP Trunks from ITSP?

Postby david55 » Wed Aug 08, 2012 9:09 am

Use qualify to detect the loss of a trunk. Use a global variable to track which one you last used, when both are available. Analyse the HANGUPCAUSE to determine whether calls fail due to a down trunk or a more distant problem.

Ask support questions in Asterisk Support!
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: How to setup failover for multiple SIP Trunks from ITSP?

Postby dev_shah » Wed Aug 08, 2012 2:16 pm

Thank you David. Your answer helped to resolve the problem.
I did the following to address my problem

file: /etc/asterisk/sip.conf
--
--
[sip_trunkA-out]
---
---
qualify=yes
qualifyfreq=30 ; Qualification: How often to check for the host to be up in seconds
; and reported in milliseconds with sip show settings.
; Set to low value if you use low timeout for NAT of UDP sessions
; Default: 60
qualifygap=60 ; Number of milliseconds between each group of peers being qualified
; Default: 100

/etc/asterisk/extensions.conf
------
--------
same => n,Set(NETWORKSTATUS=${SIPPEER(sip_trunkA-out,status)})
same => n,Gotoif($[NETWORKSTATUS=UNREACHABLE]?101:)
same => n,Dial(SIP/sip_trunkA-out/${EXTEN:1})
same => 101,Dial(SIP/sip_trunkB-out/${EXTEN:1})

[Logic: If TrunkA is unreachable, go to TrunkB;
Please also note that you might have to customize the dialplan to meet your requirement]

I hope this will help someone else who is looking the solution for the similar problem.
dev_shah
Newsterisk
 
Posts: 5
Joined: Tue Jan 25, 2011 9:13 am

Re: How to setup failover for multiple SIP Trunks from ITSP?

Postby cutee4 » Tue Feb 12, 2013 2:16 am

Hey David, Same issue was with me, I was searching for the answer.. Thanks to post it here. I hope you will help me if I need.
http://www.plagiarismsoftware.org/
http://definitions.uslegal.com/p/plagiarism/
[url=http://www.wiu.edu/users/mfbhl/wiu/plagiarism.htm]http://www.wiu.edu/users/mfbhl/wiu/plagiarism.htm[/url
cutee4
Newsterisk
 
Posts: 1
Joined: Tue Feb 12, 2013 2:07 am


Return to Asterisk General

Who is online

Users browsing this forum: No registered users and 4 guests