Ok so here is how i have dealt with ip changes every 12 hrs or so.. I know its horrible not having a static ip but our provider doesnt offer it for the package we have in order to get it they want to change about 240 dollars extra a month for business class internet.
So i have copied together a mixture of information i found online and basically set it up that if the public ip changes it then takes and restarts asterisk via service asterisk stop then sleep for 5s then service asterisk start...
I am by far the worst person in the world to rely on for scripts i seriously wish i understood shell scripts.. But here is what i have.
For this to work you need install
sudo apt-get install sendmail sendmail-bin
sudo sendmailconfig
If this is the first time using crontab -e command it will ask you which type of editor you wish to use 1 nano 2 vim I usually select option 1 for nano.
crontab -e
Put this line in crontab -e
*/2 * * * * sh /etc/asterisk/ip.sh
To exit crontab -e press ctrl + x it will then ask if you want to save the settings Y for yes then enter.
Create ip.sh I put it in /etc/asterisk/ folder
nano ip.sh-
#!/bin/bash
#### ip.sh shell script
#### this script sends mail to an email address if ip changes
#### Also restarts asterisks if the ip changes.
touch old_ip.dat
read T1 <index.html
read T2 <old_ip.dat
if [ "$T1" = "$T2" ]; then
echo "IP Is the same doing nothing";
else
service asterisk stop
sleep 5s
service asterisk start
fi
rm old_ip.dat
mv index.html old_ip.dat