I have this same scenario in many environments:
We have two Asterisk 1.6.2 servers, HO and BR. Both of them are behind ADSL routers like Linksys. We have port 4569 forwarded to the Asterisk. The public IP address of both is dynamic, it changes every 8 days, so we are using DynDNS.
Here is iax.conf of HO:
iax.conf at BR server has the opposite config.
Say that HO public IP address when we started HO server was 18.104.22.168, then we have the following:
iax2 show peers
BRHO/BRHO 22.214.171.124 (S) 255.255.255.255 4569 OK (211 ms)
After 8 days, the IP address changes to 126.96.36.199, then we have:
BRHO/BRHO [color=#FF0000]188.8.131.52[/color] (S) 255.255.255.255 4569 UNREACHABLE
Then, if I restart Asterisk, it becomes:
BRHO/BRHO 184.108.40.206 (S) 255.255.255.255 4569 OK (237 ms)
This means that Asterisk is not resolving the new IP address 220.127.116.11 of br.dyndns.org when it’s being changed until we perform manual restart.
Is there any solution to let Asterisk refresh it’s DNS records frequently?
Get a better ISP. Changing address every 8 days is either plain broken or a deliberate attempt to prevent the use of servers.
Alternatively restart Asterisk whenever the address changes.
Actually in our region, getting a static IP address will cost five times more expensive than dynamic one.
Isn’t there any solution to our issue using dynamic?
Ensure you have activated the dnsmanager in asterisk.
in both servers install a dyndns like inadyn o ddclient, sometimes the builtin client in the routers dont work.
If there were really good solutions to dynamic addresses, ISPs wouldn’t charge extra for static ones. Basically I think you are using a domestic type account for business use and the ISP really would prefer you to buy the business account.
The address allocation protocols are designed to give you the same address every time, unless you fail to renew for an extended period. Changing addresses tend to indicate an ISP who doesn’t want the account used for business use.
Basically, for good performance reasons, Asterisk is not going to make DNS requests every time. Also, I don’t think dynamic DNS services will like your updating every second. Any calls in progress are going to break, even if you reresolve for every INVITE.
Thank you. dnsmanager seems to be helpful, I have never used it before. I have just enabled it, and then I will wait few days to see if it solves the problem.