FreePBX 15 behind NAT: HowTo setup dynamic external IP config?

Hi all!

My FreePBX 15 is up and running behind a Fritz!Box via NAT.
Everything worked fine for some time but now I found that my external “static” IP is not really static and it may be changed.
So I can’t no longer use in SIP Settings -> General SIP Settings -> NAT Settings a fixed “External Address” via “Detect Network settings”.

I want to use our own web server to get my external IP address and no external service.
For example

wget http://some.web.address/cgi-bin/addr.cgi -q -O - | awk ‘/REMOTE_ADDR/ {print$2}’

I looked at the documentation and the Forums but I found no information how to use such a setup.

Any clue?


It sounds like you need to do two things:

  1. Change to PJ-SIP - if Chan-SIP looses it’s IP address, it goes catatonic and you have to reboot Asterisk to get it back.
  2. Add a Dynamic DNS entry to allow the graceful transition of the external address when it changes.
1 Like
  1. I use actually chan_pjsip

  2. Is it not possible to use a custom shell command as shown in my initial mail? How about changing a configuration via shell command after an IP change occurred? This would be pretty easy to set up but I have no clue what configuration has to be changed.

Yes, that is possible and has been discussed here are length. @comtech and @pitzkey (IIRC) both have provided considerable Intellectual Property on this subject in the past.

1 Like

Thanks for your help. I will dig more into the forum to find related posts next week.

My solution is now the usage of a DNS name in the External Address field of the SIP settings.
This name is resolved via “/etc/hosts” entry.
Now I use a cron job to check frequently the external IP. In case it did change the hosts file is updated.

1 Like

You don’t need the cron job (and shell script, I assume) to modify /etc/hosts. While chan_sip “always” supported a FQDN in FPBX External Address, chan_pjsip just got this capability relatively recently (some time in 2018).

See this blog post:

and this Community thread:

I set up FPBX 14 with a FQDN in External Address in 11/2018 – works fine.

(This assumes that you have dynamic DNS for the FQDN. Many routers can provide dynamic DNS updates.)

1 Like

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