Click to See Complete Forum and Search --> : Being sent IP of eth0 when it changes???
slewis1972
01-07-2003, 06:03 AM
I use the dyndns.org and the webmin module to update it when my ip changes onmy Redhat8 server. I ahve been finding that this is failing - it cannot connect to dyndns.
What i would like to do while I fix the above is get a email sent me at x address when the ip address of eth0 changes.
The thing is - i have not a clue on how to do it.
Otherwise, I could always setup a cron job to email me the ip every hour.
Can anyone help?
Scott
Alex Cavnar, aka alc6379
01-08-2003, 12:46 PM
Yes, you could, actually.
Just set the crontab job to run
ifconfig eth0 > ~/ip_addy
every hour, and then have your favorite mailer (I don't do mail on my box, so I can't help you here) mail you the file ~/ip_addy every hour.
I used to make a lot of cron jobs, but I've forgotten how to. Fortuantely, the info and man pages on cron and crontab are pretty good.
bruce1271e1271
02-01-2003, 08:59 PM
I had the same problem.
I wrote a few scripts to
1) Every night(3am) take down eth0 and then Bring it back up.
2) Compare the New IP to the previous IP and email me if there is a difference.
3)I also added the script to my boot-up files to run on every boot-up to compare to previous shutdown.
I used Perl to write the simple scripts..took ~1/2 Hour.
Do something like this and then you can be notified.
Good luck.
z0mbix
02-02-2003, 08:11 AM
Create a script something along the lines of:
#!/bin/bash
IP=`/sbin/ifconfig eth0 | fgrep "inet ad" | cut -f2 -d":" | cut -f1 -d" "`
echo $IP > .currentIP
mail -s "New IP: $IP" foo@bar.com < .currentIP
Obviously change the eth0 to whichever interface is required.
Just add this to the script that is run everytime you connect. This differs from distro to distro.