VOIP / Asterisk Fail-Over Possibilities?

I am wondering about fail-over capability with VOIP, in an asterisk environment and SIP peers or UA devices, across the WAN or internet.

I want to eventually have fail-over in case the main internet connection that my asterisk server is on, goes down.

I was hoping to do this through some sort of dynamic DNS with my domain through Godaddy but apparently they do not support dynamic DNS.

I have my domain setup through godaddy, and I created an A record for voip.mydomain.com, pointed it to my asterisk WAN IP and thought about using that address in my UA or sip peers, instead of the IP address.

Is there a way to have a solid fail-over with sip peers in an asterisk environment?  I think the solution has something to do with DNS SRV, but I am not too familiar with how it works.  Does using DNS SRV cause more problems with things like, 1 way audio etc?  

Who is Participating?
If you want to protect against the possibility of your main Internet connection failing, then you must consider the following:
a) which elements of your service will be affected
b) what options are available to you to provide an alternative solution
c) what level of service you want to be able to provide under those circumstances.

Any remote IP phones that were registered with your Asterisk PBX will lose service, but any IP phones being used as extensions on the LAN will be ok; Any SIP trunks or similar VoIP based PSTN connections will be out, but any analogue or ISDN connections will still work.

The only direct alternative to a broken Internet connection is to a second Internet connection through a different provider and on different cables. Many business grade firewalls/routers can accommodate dual WAN connections and the failover would be transparent for outbound connections but for inbound all your IP addresses will change (unless you are using some serious commercial equipment with BGP). To overcome the problem of your IP addresses changing, remote IP phones would need to use DNS-SRV or failover DNS. GoDaddy don't do failover DNS, but DNSMadeEasy and Netriplex do. However, there will be latency in the phones detecting that the old registration has failed before they re-register using the new addresses. DNS-SRV does not cause problems of 1-way audio.

What is the minimum level of service that must be maintained? Perhaps remote users would be ok provided they can still make calls to the PSTN, in which case a prepay VoIP account configured on one of the spare line keys might be adequate. If they need to maintain connectivity with the Asterisk PBX then you'll need the backup Internet route and the DNS-SRV or failover DNS.

What about incoming calls to the PBX? If they are all delivered over VoIP then you will have problems. If Asterisk registers with the service provider then it may not re-register itself (using the new IP address) until the normal registration expire time is reached - that can be half an hour or more. If your VoIP service provider connects to you by IP address then they will have to operate some kind of failover to reach you on the alternative IP address. Some VoIP service providers will be able to offer failover routing for your inbound calls, provided you have an alternative path that they can deliver to - that could be via conventional ISDN or analogue trunks.

What I've mentioned there just relates to failure of your Internet connection. Have you also considered failure of the Asterisk server, your router, firewall or LAN switch?
Ron MalmsteadInformation Services ManagerCommented:
Asterisk supports failover in a simple way...and others have taken it further, with load balancing techniques that i've never tried myself...

Use multiple dial statements in order of preference.


exten => _NXXNXXXXXX,1,Dial(zap/g2/${EXTEN},30)
exten => _NXXNXXXXXX,1,Dial(${EXTEN}@tosipprovider,30)

If the voice circuit was down, then the first dial command would fail and the second dial command would be tried, sending the call to a sip provider (your other asterisk box used for failover).
Ron MalmsteadInformation Services ManagerCommented:
Priority typo corrected...

exten => _NXXNXXXXXX,1,Dial(zap/g2/${EXTEN},30)
exten => _NXXNXXXXXX,n,Dial(${EXTEN}@tosipprovider,30)
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jkocklerAuthor Commented:
Okay thanks for that side of it, but I am wondering about the other side of it.

You explained how asterisk could go to a different service provider if possibly the service provider went down.

My question pertains more to how the sip peers can always find the asterisk server.  So for example, I have a Linksys ip phone at a remote site.  It connects to asterisk at Public IP address  If the ISP hosting the ip address goes down, I am looking for a way for the linksys phone to still be able to contact the asterisk box.  The Asterisk box stays online, because I can have a dual WAN port firewall, that rolls over to a secondary ISP.  In the event that it rolls over to the secondary ISP, the PUBLIC IP of asterisk would change to for example 33.333.33.333.  

How can I make sure the Linksys IP phone will always find the asterisk server, even on the alternate IP address??
Ron MalmsteadInformation Services ManagerCommented:
In this case, you have a few options...all of which require having two internet connections.

1, get your DNS hosted with someone who supports dns failover and server monitoring, so if your server shows offline it will update the host record to the failover ip address connection.  In this case you would have clients registering to a hostname... for example    voip.yourdomain.com, rather than having them register to an IP address.  There could potentially be a short outage in service however...which is always the case when you are dealing with dns record changes.

2, you could put the voip traffic through a vpn,....and on many firewalls/routers you can use a vpn failover IP address.  In this case your clients wouldn't be registering to a public ip, but rather the internal , local ip address of your asterisk server and they would have to have vpn capability.

3, On the Linksys phones you have the ability to assign multiple extensions to different sip proxies.  In this case you would create identical settings for extensions 3 and 4 as you would 1 and 2, but with the failover address as the IP address.  You could also use 3 extensions on the main IP and one extension as a backup if you chose.  In this case I would leave the secondary failover connection in a down state, and it would be a manual intervention to restore service by bringing it up.  This would eliminate 1 or 2 extensions however on phones that support 4, also the phones would experience a delay in re-registering, depending on how fast your response time is and the registration interval you setup..
Ron MalmsteadInformation Services ManagerCommented:
Worth noting, is that calls that were in progress at the time of the failover would be terminated immediately, no matter which option you choose.  These are options to failover the registration of the phones and the connection path.
Another note - you will not be able to use the externip parameter in sip.conf. Instead you must use externhost and externrefresh. Set externhost to the host name used in your failover DNS A record and set externrefresh to something greater than the default 10 which is too low. I think 120 is ok for the refresh interval.
jkocklerAuthor Commented:
Thanks for all the information !!! Very helpful.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.