SSH & Email on WAN IP change?

cpu.

Executive Member
Joined
Jun 23, 2010
Messages
5,713
Reaction score
898
Location
Here
Inspired by ponder's venture into SSH and no-ip/DynDNS, I decided I want to do it too. Last I tried DynDNS my router logs showed lots of new activity.

This time round I want to try it old-school with email (or getting with the times - Twitter updates) of IP changes. Anyone know of scripts or open source apps that can do that in terminal? Not googled, but tried and tested.

OS: Ubuntu Server
 
When my dynamic IP address assigned by the ISP on router resets/disconnects change, I want a script to notify me. This scripts check at regular intervals and when a change is found an email is sent to me (twitter was only mentioned as alternative that I saw mentioned somewhere in a google result).
 
But why? The whole reason for no-IP and DynDNS is to move away from an IP to a hostname? Why then in the first place use DynDNS or no-IP?
 
But why? The whole reason for no-IP and DynDNS is to move away from an IP to a hostname? Why then in the first place use DynDNS or no-IP?
I was hoping someone is stuck in the past.:) I guess I'll give that ^ another go.
 
When my dynamic IP address assigned by the ISP on router resets/disconnects change, I want a script to notify me.

I'm still not sure what you want to do but I'm sure that you could modify the no-ip/dyndns script as that updates their servers with the latest ip info.
 
I'm still not sure what you want to do but I'm sure that you could modify the no-ip/dyndns script as that updates their servers with the latest ip info.

The idea comes from before no-ip and co. It was how it was done back in the days. The reason I want it is to eliminate a third party (and less chance of intrusion attempts), but I guess that's like hanging on to a tape recorder in the digital age.
 
Well adjust their script to collect the new router ip but instead of sending the data to their server make it interact with whatever app you want to forward the data to you.
I have no idea how to do this though, I cower & wimper when I see scripts :D
 
Found a way to get my IP:
Code:
wget -qO- http://www.whatismyip.org | less > /home/username/bin/myip.txt

And then to email it to myself:
Code:
mail -s "NEW IP ADDRESS @ HOME" [email protected] < /home/username/bin/myip.txt
That ^ or possibly (haven't tested it yet. It's an adapted version of a sendmail command-combo):
Code:
echo /home/username/bin/myip.txt | mail -s "NEW IP ADDRESS @ HOME" [email protected]

Chuck it all in an executable file (named whatsmyip.sh for example):
Code:
#!/bin/bash
OLDIP=`cat /home/username/bin/myip.txt`
NEWIP=`wget -qO- http://www.whatismyip.org | less > /home/username/bin/myip.txt`
if [ "${OLDIP}" != "${NEWIP}" ]; then
echo "IP ADDRESSES DIFFERENT, UPDATING AND MAILING"
#echo ${NEWIP} > /home/username/bin/myip.txt
mail -s "NEW IP ADDRESS @ HOME" [email protected] < /home/username/bin/myip.txt
fi

The mail can't go to a remote host yet, but it's a start at least. Once I get it working I'll set a cronjob to check it every hour.

Off to figure exim4 out...
Anyone that know how to get mail from Ubuntu passed any obstacles like inactive firewall, router and gmail?
Apps: mail, exim4. (On Ubuntu Server 10.04)
 
Top
Sign up to the MyBroadband newsletter
X