Update your dynamic IP with Afraid.org
Say you run a server of some kind at home and you don't have a static IP (who wants to pay the extra cash?), and you need the IP to update after your router restarts. It's simple with afraid.org and a bash script run by the cron system. This is the bash script:
#!/bin/bash #checks this ip against dynamic ip and updates it #make sure the update worked function updatetest { echo $FREEDNS | mail -s "IP updated" justin } #get this actual ip THISIP=`wget -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'` #get ip dns DNSIP=`host justhoff.chickenkiller.com | sed -e 's/.*address //' -e 's/<.*$//'` #if either empty, then stop function testip { IP=$1 TEST=`echo "${IP}." | grep -E "([0-9]{1,3}\.){4}"` echo "$IP" | nawk -F. '{ if ( (($1>=0) && ($1<=255)) && (($2>=0) && ($2<=255)) && (($3>=0) && ($3<=255)) && (($4>=0) && ($4<=255)) ) { } else { exit 1; } }' } #test if they are same numbers OR run update ( testip $THISIP && testip $DNSIP ) && ( [ $THISIP = $DNSIP ] || { FREEDNS=`wget -q -O - http://freedns.afraid.org/dynamic/update.php?YOUR_ID` ; updatetest ; } )
As you can see, the script checks your IP with wget and compares it to the IP listed by afraid.org. If the two match, it's done. If not, it sends the update message to afraid.org. Afraid.org is a free dynamic DNS server. They give you a subdomain and you point it to your server.
Category: