Switching External IP Automatically

We have two different internet feeds coming to our facility; a primary and a secondary that only kicks on if the primary fails. Both have their own routers, with their own unique WAN IP addresses go to two different ISPs. The failover process between disparate ISPs is automated by one of the routers.

Our PBX server sits inside the firewall behind these routers. The server works fine via both internet links, but, I have to manually go into SETTINGS/Asterisk SIP Settings and manually click the “Detect Network Settings” button to get it to re-populate the field with the correct WAN IP (External IP) of each of the respective routers we have when the link fails over, or fails back.

Is there some way to automate this so you do not have to login and manually re-select the External IP?

Although not viable for most FreePBX users, have you ruled out proper multihoming, with your own autonomous system number?

Do you have dynamic DNS that reflects the current working route?

Are you using chan_pjsip? I believe it has better support for unstable IP addresses.

HI

Thanks for reply. This system is installed at a small operation so setting them up with an ASN would be a bit of overkill - also their routers would not support an ASN config (running a quad core Asus router, which works REALLY well for their needs). They do have DDNS setup which works fine as well and does reconverge correctly to the active WAN IP. Trunks are setup with pjsip.

I don’t have personal experience of this, but I believe the feature described in PJSIP: DNS Manager (dnsmgr) and Full Dynamic Hostname Support, Coming Soon! ⋆ Asterisk is now implemented. I don’t know whether there is FreePBX support, or otherwise how to enable it under FreePBX.

Hmmm - that looks like EXACTLY what I am looking for. Anyone know if this is implemented supported in FreePBX 17?

Did you figure it out?

You could probably write a bash script to curl the current IP and compare it to the current IP that’s interesting the kvstore tables in SQL. If it’s different replace the current with the new, then do an fwconsole restart. Throw that into crontab every 5-10 minutes or whatever

1 Like

@Eris - Yeah, that would be the only way to have it auto update. You would need a custom script on a cron job. Also the fwconsole restart is important because a reload (apply in the webUI) may not update the public IP in the SIP packets.

A good site to curl for a public IP is ifconfig.me; no parsing is needed, it just gives the public IP.

1 Like

@swebster , I suggest you look into implementing DNS SRV records for your box. most phones and trunks can do that.

Hello @Eris - I just remembered this can be done with our Sangoma SBC product in front of the PBX. As the SBC will allow you to have two different IPs.

This means we will send from private IP #1 and your router will need to lock that IP to ISP #1. When the SBC notices this is down (sip OPTIONS), then the SBC can send from private IP #2 and your router needs to lock to ISP #2 when it sees private IP #2.

This would allow the failover to occur within the SBC itself. On the ITSP side this would require two trunks, as both IPs would need to be registered at all times. If your ITSP is doing IP auth then it may support a failover IP, but it would need to respond to OPTIONS when the primarily IP is up.

There also may be other solutions that can do this as well that aren’t from Sangoma. The trick here is having two different IPs on the same device, and having the router lock each to its own public IP. Then having the SIP device send OPTIONS and failover to the secondary ITSP when the primary is down.

This reason this is a good solution is there is no configuration updating needed. Each private IP assigned to the SBC is locked to a public IP in the router, and in its own configuration. So the only dynamic part is the actual failover between the primary and secondary trunk.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.