About a month ago, Dyndns.org shut down his free dynamic dns service, disrupting service to hundreds of thousands of home server installations, shame on them!
Many Asterisk setups relied on this to overcome nat problems with dynamically assigned WAN ips (using the externhost=xyz.dyndns.org directive)
Here’s a tiny shell script to automatically update your externip directive from sip.conf reflecting your actual WAN ip address:
Nice idea, but at least the script should check whether the IP has changed or not - probably by saving the actual IP to a file. This will avoid non necessary reloads.
#!/bin/bash
doreload=0
wanip=`curl -q tnx.nl/ip`
if [ -f /tmp/oldip.txt ]; then
oldip=`cat /tmp/oldip.txt`
[ "$wanip" != "$oldip" ] && doreload=1
else
doreload=1
fi
echo $wanip > /tmp/oldip.txt
if [ $doreload -eq 1 ]; then
sed -i 's/externip=.*/externip='"$wanip"'/' /etc/asterisk/sip.conf
asterisk -rx 'sip reload'
fi