no-ip – self made script

Sometimes my DSL Modem (that has a build in dyndns Client) hangs, and it stops updating
the Server.

I have some notes on my Atom based Linux Server at home and it bugs me if i can’t connect via
ssh from the office.

I wrote a script to mail me the new public ip address as soon as it is changing.
If you have a linux pc/server at home you can do the following by yourself:

put the following php script to your webserver – give it a fancy name like “myip.php”
<blockquote>&lt;? echo $_SERVER[‘REMOTE_ADDR’] ?&gt;</blockquote>
Start the following  script
<blockquote>crontab -l

# m h  dom mon dow   command
0   *   *   *  *    ~/bin/update_ip/;/dev/null 2&gt;&amp;1

on your local linux server:

cd ~/bin/update_ip

LAST_IP=`cat .last_ip`
IP=`curl -s -o – http://mywebserver/myip.php`
echo “last IP : $LAST_IP – new IP: $IP”
if [ $LAST_IP = $IP ];
echo `date +%d.%m.%y-%R` “ip unchanged”
echo “new ip: $IP”
cat .last_ip | mailx -s “New-IP $IP” MAILADR
echo “$IP” &gt; .last_ip
echo `date +%d.%m.%y-%R` “new IP :$IP” &gt;&gt;ip.log



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s