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


(Hs) #1

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?

TIA,
HS


(Dave Burgess) #2

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.

(Hs) #3
  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.


(Dave Burgess) #4

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.


(Hs) #5

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


(Hs) #6

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.


#7

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:

https://blogs.asterisk.org/2018/01/10/pjsip-dns-manager-dnsmgr-full-dynamic-hostname-support-coming-soon/

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.)


(system) closed #8

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