<div dir="ltr"><div>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.</div><div><br></div><div>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...</div><div><br></div><div>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.</div><div><br></div><div><div>For this to work you need install</div><div>sudo apt-get install sendmail sendmail-bin</div><div>sudo sendmailconfig</div><div><br></div><div>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.</div><div>crontab -e</div><div><br></div><div>Put this line in crontab -e</div><div>*/2 * * * * sh /etc/asterisk/ip.sh</div><div><br></div><div>To exit crontab -e press ctrl + x it will then ask if you want to save the settings Y for yes then enter.</div><div><br></div><div>Create ip.sh I put it in /etc/asterisk/ folder</div><div>nano ip.sh-</div><div>#!/bin/bash</div><div>#### ip.sh shell script</div><div>#### this script sends mail to an email address if ip changes</div><div>#### Also restarts asterisks if the ip changes.</div><div>touch old_ip.dat</div><div><br></div><div>wget <a href="http://whatismyip.org">whatismyip.org</a></div><div><br></div><div>read T1 <index.html</div><div>read T2 <old_ip.dat</div><div><br></div><div>if [ "$T1" = "$T2" ]; then</div><div> echo "IP Is the same doing nothing";</div><div>else</div><div>(echo "From: <a href="mailto:Ipchanged@myrepeater.com">Ipchanged@myrepeater.com</a>"; echo "To: <a href="mailto:email@email.com">email@email.com</a>"; echo "Subject: IP Address Update"; echo; echo "Computer's IP Changed. The new IP is:"; cat /etc/asterisk/index.html) | sendmail -f <a href="mailto:Ipchanged@myrepeater.com">Ipchanged@myrepeater.com</a> <a href="mailto:email@email.com">email@email.com</a></div><div>service asterisk stop</div><div>sleep 5s</div><div>service asterisk start</div><div>fi</div><div><br></div><div>rm old_ip.dat</div><div>mv index.html old_ip.dat</div></div><div><br></div><div>### End of shell script ip.sh</div><div><br></div><div><br></div><div><br></div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-family:arial;font-size:small">Loren Tedford (KC9ZHV) <br>Email: <a href="mailto:lorentedford@gmail.com" style="color:rgb(17,85,204)" target="_blank">lorentedford@gmail.com</a></div><div style="font-family:arial;font-size:small">Main Line:1-631-686-8878 Option 1 for Loren.</div><div style="font-family:arial;font-size:small">Fax Line 1:1-618-551-2755</div><div style="font-family:arial;font-size:small">Fax Line 2:1-631-686-8892 (New Fax line)</div><div><font face="arial" size="2">Cell: 618-553-0806</font><br></div><div style="font-family:arial;font-size:small"><a href="http://www.lorentedford.com/" style="color:rgb(17,85,204)" target="_blank">http://www.lorentedford.com</a></div><div style="font-family:arial;font-size:small"><a href="http://www.kc9zhv.com" target="_blank">http://www.kc9zhv.com</a></div><div style="font-family:arial;font-size:small"><a href="http://hub.kc9zhv.com" target="_blank">http://hub.kc9zhv.com</a></div></div></div></div></div></div></div></div>
</div>