How to reload the new external IP automatically

Hello everyone
I do not have an external static IP but I have an FQDN and it works fine for internal and external phones
until the ISP changes the external IP in the router, the sound is cut off and the connection cannot be made. so to solve this problem I must click on (Detect Network Settings) in Asterisk sip settings.
Is there any way to reload the new external IP automatically instead of pressing Detect Network Settings button and submit and apply config every day?

Your machine is not self aware of it’s DDNS resolution at any one time, there are any number of DDNS clients that essentially ‘poll’ for your current IP and update your routing locally, you can tune the frequency of updates but there will always be latency for any connections because of the TTL and the need for your current IP to be propagated around the globe.

The real solution to this is to find a better ISP. Are you in a country with rather limited choices?

no way to change ISP They are monopolized, and do not provide a static IP to individuals. it is possible for companies or institutions. so I use the NOIP but it’s impractical.

A dynamic IP doesn’t need to keep changing. That’s sometimes done to stop people running servers.

are there experts who have other solutions?

I don’t think it is a problem many experts would have.

Can the router be configured to log using syslog? If so, in principle you could direct the syslog stream to syslogd on the FreePBX box and from there pipe it to code that looks for messages about address changes and shells out to asterisk -rx, if it detects one, but there re lots of details that would need to be filled in.

Nothing will save calls in progress at the time of the change, and you cannot stop a remote client caching the old address.

Yes there is absolutely a solution that a few of our clients that cant get static IP do for this…

You sign up for a www.noip.com account. Put their update client on an always on computer, security gateway/router, linux box, etc. at this location and every time your Dynamic IP changes it will automatically update your NOIP domain name…

You then have a few options…you can use that domain name with FreePBX and your done… Or if you already have FreePBX setup with a FQDN and you dont want to change it like for example voip.mydomain.com you can just edit the your DNS records for that FQDN and add a CNAME entry to your noip.com domain name…

Multiple ways to handle this

I guess, in theory, the PABX could hand off the call to a new IP by generating a REFER, but I could imagine that some providers would consider the session source address changing wthout warning to be a security breach. In any case, it isn’t something that Asterisk is designed to support.

Simply add your NOIP hostname at:

Settings → Asterisk SIP Settings → NAT Settings → External Address: myhostname.no-ip.biz

noipname just sounds like a dynamic DNS server, and I understood the OP to say they are already using one. I believe the OPs problem is that Asterisk doesn’t do a DNS lookup of its own address for every single request; that would normally be an abuse of DNS, even if the TTL was set to 1 second. He wants Asterisk to start using the new address immediately the interface address changes.

Their other problem seems to be that they live in a country with one ISP, which is one that will not sell business quality accounts to the general public.

This adds myhostname.no-ip.biz to /etc/asterisk/pjsip.transports.conf:

external_media_address=myhostname.no-ip.biz
external_signaling_address=myhostname.no-ip.biz

See: PJSIP: DNS Manager (dnsmgr) and Full Dynamic Hostname Support, Coming Soon! ⋆ Asterisk

Actually, I did what you post but it didn’t work
I will explain the issue to you
Everything works fine until I restart the router and normally the external IP changes
What happens next is all extensions can make calls and ring, but they don’t hear each other and auto disconnect a call.
Until I press a button (Detect Network Settings) and then everything is fine again

Are you talking about extensions on the local network? You shouldn’t be cold starting a router whilst it is in use. That may well remove all the automatically created entries from its DHCP tables. If you are trying to get it to reinitialise the ISP connection, you should just issue appropriate commands to do that, not completely power cycle it or otherwise hard reset it.

Alternatively, given this is a home network, so quite small, you should simply create static DHCP settings for all your phones. You should already have a static one for the FreePBX machine, or should not be using DHCP at all for it.

Do you have a local network based DNS server? If so, make sure it gets dynamic change of IP. Polling your own DNS server frequently is no problem. Something like this: linuxhint dot com slash configure-ddns-synology-nas

Unless I am understanding this wrong, part of the problem is the WAN DHCP client pulling for a new IP and getting it while there are active calls happening. This would mean any DDNS has already been resolved and an IP added into the flow. I’m pretty sure at this point new requests will get a DNS lookup on the DDNS FQDN but existing requests are going to lose routing because previous IP is gone.

If this is a business then ask for a static IP. If this is residential then move to the cloud.

I’m talking about calls and extensions through the internet, not LAN
All internal LAN calls have nothing to do with the external router’s IP address, so it works fine

Yes, you understood what I mean. and for clarification, I can log in to the local server through the website GUI from outside my network, even if the router’s external IP has changed, but calls cannot be made.

Because you either know the new IP or your DNS update. Calls in session wont look up new IPs

As I said a long way back, calls in progress would be lost.

This cannot reasonably be fixed from the Asterisk end as it the phone that has locked in the old address. Asterisk would have to initiate a transfer to fully recover, and even that might be rejected by the phone, and would certainly cause protocol problems, as packets used in closing out the old session would be lost.

The design of IP assumes that IP addresses are pretty stable. It’s resilience is in terms of finding alternative routes to an IP address, much more than finding alternative IP addresses for a domain name. One is not expected to do a DNA lookup after you have bound to a socket.

It would be addressing a case that simply wasn’t economically important to Sangoma, and probably not important to third party developers, as they would probably have good ISPs.