IAX2 register issue

Good day!

I recently start using IAX2 to connect a branch office. It works, the problem we have is that we don’t have static IP on both sides, the main office has dynamic IP and the branch also. We use dynDNS pro so we use hosts names to make the IAX connection. And for this reason I assume that both * box can’t register to each other sometimes. Today I check the IAX2 peers status and server A (the main office) had registered server B (the branch) but server B hadn’t registered server A. and today I couldn’t assume it was an IP problem because I could do ssh to the remote server (server B) using its hostname from dyndns, the same name server A has in its configuration.

Is it possible that when * has to resolve hostname it just resolves once and won’t refresh that value, because I think that happened, it is possible that the server B IP asterisk has on its records was the IP from the day before and not the actual IP, so today when it was trying to connect it couldn’t get it because it has the wrong IP.

I restart the asterisk service on server A but it doesn’t resolve the problem, so it reboot server B too, and then the problem was gone.

For now I will add a task on crontab to reboot both server each morning so they stay connected during the day, but I would like to provide some technical solution.

I hope you can help me out with this issue :smiley:!

Here is Server A and B Iax Config:

Server A

[general]
register => serverA:passA@serverB.dyndns.com

[serverB]
type=friend
host=dynamic
trunk=yes
secret=passB
qualify=yes
context=default

Server B

[general]
register => serverB:passB@serverA.dyndns.com

[serverA]
type=friend
host=dynamic
trunk=yes
secret=passA
qualify=yes
context=default

Asterisk does not handle dynamic IP addresses too well. You will see that if you search the forum.
Asterisk was built to be a server application, and as such intended to use a static IP address on which it is accepting requests. So I am not too sure that your setup is possible without making a cronjob that restarts the Asterisk process when the public IP address switches.

The best solution of all would be to have static IP’s on both sites. Another good solution is also to use routers that support VPN’s and run all the VoIP comunication via the VPN connection.

Also, the big problem is not the use of dynamic addresses, but the failure to renew address leases. The latter may be a deliberate attempt to prevent the use of servers on low end service products.