Asterisk with sip trunks & two external ip address for failover

We have an Asterisk 11 PBX with two sip trunks and two different internet connections.
Each of the sip trunks is registered by IP of each of the internet connection that we have to our provider.

Is it possible without using a second Asterisk PBX to have failover in the case of our primary internet connection going down, so the PBX fails overs to our backup sip trunk leaving the office by our back up internet connection?

Currently I can’t see a way to get this to work without manually editing the external ip within sip.conf. Other options I have taught of is using a second PBX and IAX but don’t want to go down that route unless necessary.

Does Asterisk 13 with PJSIP offer anything to solve this type of problem?

You say that you have two sip trunks that each trunk registers through a different internet connection. If you have this configuration already working why do you need to change the externip in sip.conf when the first internet connection is down?

Yes in the transport section check the option external_signaling_address

example :


Sorry I should have worded the question better.
Currently we have a single SIP trunk with a single end point on our side of the trunk, the trunk accepts traffic from a single IP address.
We have a fibre WAN connection as our main office connection and a backup ADSL connection, each connection has it’s own IP address.

Currently if the main WAN connection goes down we need to contact our SIP trunk provider and get them to change the IP address the trunk accepts traffic from and then change the “externip” within sip.conf. The setup allows for a period of time where the office has no incoming/outgoing calls.

What we want to achieve is in the event of the main office wan going down to have the trunk automatically reconnect over the backup ADSL connection.

We have asked our trunk provider to change our trunk so it has two end points on our side of the trunk this allows it to accept traffic from two different IP addresses (WAN + ADSL). The problem we now have is that “externip” within sip.conf still needs to be updated manually. We want to automate this or allow for the PBX to have two “externip” within sip.conf.

Currently we are only aware of two ways to do this:

  1. Two installs of Asterisk connected via IAX, one for each endpoint of the trunk
  2. A script that changes the externip setting in sip.conf and reloads it

We are looking for other ways to do this.


Your suggestion would require moving to Asterisk 13 which is not a bad thing and seems like a better idea than my two listed above.

Since I have not looking into moving the phone system to Asterisk 13 yet I’m not too familiar with PJSIP but from my brief investigation would I not require two transport entries, each getting a one of the external IP address for the external_signaling_address?

The correct way of doing this is to get your own autonomous system number and run border gateway protocol on your routers. This also requires the use of static IP addresses. However you will probably have to be a major customer of the ISPs fo this to be possible. This will mean that both IP addresses are routable via both ISPs and is how IP was intended to work.

Unfortunately, SIP generally assumes that you are using a proper IP configuration, and when you combine a broken multi-homed configuration with NAT, you are pushing it well beyond its limits. I would go for your number (1) and number (2) is the only other option of which I can think.

Go for the first solution, configure a second asterisk, connect the two machines, put the trunk as a failover trunk in your dialplan and you are good to go.