automaticaly send an IP change
Hi, I have to support the home computers of some friends. All of them are newly converted :) to SuSE 9.2. All of them use DSL or cable Internet access. The problem is that from time to time their ISPs change the IPs of the modem, which prevents me to remotely administer the machines without asking some of the people there to check what is their current external IP by checking http://www.whatismyip.com/ or the config of the modem. Is there a script/package which can check the external IP on regular basis and send the changes to an email? Cheers Sunny
On Tuesday 14 June 2005 11:33 am, Sunny wrote:
Hi, I have to support the home computers of some friends. All of them are newly converted :) to SuSE 9.2. All of them use DSL or cable Internet access. The problem is that from time to time their ISPs change the IPs of the modem, which prevents me to remotely administer the machines without asking some of the people there to check what is their current external IP by checking http://www.whatismyip.com/ or the config of the modem.
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Yes.... just set up a cron job to send you an email (any email) on a 6 hour (or whatever) basis. You can get the ip address out of the email headers. Works well.
Sunny wrote:
Hi, I have to support the home computers of some friends. All of them are newly converted :) to SuSE 9.2. All of them use DSL or cable Internet access. The problem is that from time to time their ISPs change the IPs of the modem, which prevents me to remotely administer the machines without asking some of the people there to check what is their current external IP by checking http://www.whatismyip.com/ or the config of the modem.
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Is the host name consistent? If so, you can just do a dns lookup. If the host name changes with the IP, then that won't work. Another possibility, is a dynamic dns server, which many firewall/routes can be configured to use.
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Is the host name consistent? If so, you can just do a dns lookup. If the host name changes with the IP, then that won't work. Another possibility, is a dynamic dns server, which many firewall/routes can be configured to use.
Here's a script that I made that at first I ran every 12 hours at my house. Until I made the script below that runs hourly. Also worth noting is that this stuff is running on RedHat 7.x #!/bin/sh FILE2=`echo "/fwlog/ifconfig.txt"` touch /fwlog/ifconfig.txt ifconfig eth0 | grep inet | awk -F: '{print $2}' | sed 's/Bcast//' > /fwlog/ifconfig.txt mv -f /fwlog/ifconfig.txt $FILE2 cat $FILE2 | mail -s"IP address, ifconfig" email@gmail.com I have another script that checks the ip and only sends an email if it's changed. This may be better for you. This runs hourly. #!/bin/sh ifconfig eth0 | grep inet | awk -F: '{print $2}' | sed 's/Bcast//' > /etc/fw/ipcheck I=`cat /etc/fw/ip` #IP2=`cat /etc/fw/ipcheck` P=`cat /etc/fw/ipcheck` #echo "My ip is $IP1" #echo "My ip is $IP2" if [ "$I" != "$P" ]; then /etc/./ipshow /etc/fw/./fw rm -rf /etc/fw/ip cp /etc/fw/ipcheck /etc/fw/ip #echo "My ip is $I" #echo "My ip is $P" #else #exit 0 fi
On 6/14/05, Brad Bendily
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Is the host name consistent? If so, you can just do a dns lookup. If the host name changes with the IP, then that won't work. Another possibility, is a dynamic dns server, which many firewall/routes can be configured to use.
Here's a script that I made that at first I ran every 12 hours at my house. Until I made the script below that runs hourly. Also worth noting is that this stuff is running on RedHat 7.x
#!/bin/sh
FILE2=`echo "/fwlog/ifconfig.txt"`
touch /fwlog/ifconfig.txt ifconfig eth0 | grep inet | awk -F: '{print $2}' | sed 's/Bcast//' > /fwlog/ifconfig.txt mv -f /fwlog/ifconfig.txt $FILE2
cat $FILE2 | mail -s"IP address, ifconfig" email@gmail.com
I have another script that checks the ip and only sends an email if it's changed. This may be better for you. This runs hourly.
#!/bin/sh
ifconfig eth0 | grep inet | awk -F: '{print $2}' | sed 's/Bcast//' > /etc/fw/ipcheck
I=`cat /etc/fw/ip` #IP2=`cat /etc/fw/ipcheck` P=`cat /etc/fw/ipcheck`
#echo "My ip is $IP1" #echo "My ip is $IP2"
if [ "$I" != "$P" ]; then /etc/./ipshow /etc/fw/./fw rm -rf /etc/fw/ip cp /etc/fw/ipcheck /etc/fw/ip
#echo "My ip is $I" #echo "My ip is $P"
#else #exit 0 fi
Hi Brad, thanks a lot for the scripts. As in my situation, the external IP of the modem changes, not on the computer, I have modified the "get" part of your second script to: curl www.getip.com | grep title | awk -F':: ' '{print $2}' Now ... I guess I can understand what you have in the script so far ... :), but I do not see the sending part in the "if". Cheers Sunny
Hi Brad, thanks a lot for the scripts. As in my situation, the external IP of the modem changes, not on the computer, I have modified the "get" part of your second script to:
Yeah, my linux firewall/router gets the public IP not my cable modem.
Now ... I guess I can understand what you have in the script so far ... :), but I do not see the sending part in the "if".
Sorry, after I was looking at it the second time I realized what it does. The bottom script compares the IP addresses. The top script does the sending and the bottom script calls the top script. So I do use both. The bottom script runs once and hour and in-turn calls the top script. Of course you can run the scripts as often as you like. I can easily live with a 1 hour down time. However, my IP hasn't changed since my box has been up, 140 days. BB
On 6/14/05 11:40 AM, "James Knott"
Sunny wrote:
Hi, I have to support the home computers of some friends. All of them are newly converted :) to SuSE 9.2. All of them use DSL or cable Internet access. The problem is that from time to time their ISPs change the IPs of the modem, which prevents me to remotely administer the machines without asking some of the people there to check what is their current external IP by checking http://www.whatismyip.com/ or the config of the modem.
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Is the host name consistent? If so, you can just do a dns lookup. If the host name changes with the IP, then that won't work. Another possibility, is a dynamic dns server, which many firewall/routes can be configured to use.
Something like: http://www.dyndns.org/ Does wonders. Also they list routers that work with their system...you can get them around here for under $10. Or the software version: http://www.dyndns.org/support/clients/dyndns.html Personally, go with the hardware version. That way if you are working on your server, you aren't "down". -- Thanks, George "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." Benjamin Franklin
On Tue, 2005-06-14 at 10:33 -0500, Sunny wrote:
Hi, I have to support the home computers of some friends. All of them are newly converted :) to SuSE 9.2. All of them use DSL or cable Internet access. The problem is that from time to time their ISPs change the IPs of the modem, which prevents me to remotely administer the machines without asking some of the people there to check what is their current external IP by checking http://www.whatismyip.com/ or the config of the modem.
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Cheers Sunny
Why not have them register with dnydns.org (it's free) and then you could always use the same name to access their computers. -- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998 "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners." -Ernst Jan Plugge
On Tue, 2005-06-14 at 14:10 -0400, Ken Schneider wrote:
On Tue, 2005-06-14 at 10:33 -0500, Sunny wrote:
Hi, I have to support the home computers of some friends. All of them are newly converted :) to SuSE 9.2. All of them use DSL or cable Internet access. The problem is that from time to time their ISPs change the IPs of the modem, which prevents me to remotely administer the machines without asking some of the people there to check what is their current external IP by checking http://www.whatismyip.com/ or the config of the modem.
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Cheers Sunny
Why not have them register with dnydns.org (it's free) and then you could always use the same name to access their computers.
I also use ddclient to check for an IP address change every 5 minutes so I never have to go more than 5 minutes without the ability to connect. Imagine losing the remote connection and having to wait a hour to connect again if the friend isn't around to tell you the new IP address. -- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998 "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners." -Ernst Jan Plugge
On 6/14/05, Ken Schneider
On Tue, 2005-06-14 at 14:10 -0400, Ken Schneider wrote:
On Tue, 2005-06-14 at 10:33 -0500, Sunny wrote:
Hi, I have to support the home computers of some friends. All of them are newly converted :) to SuSE 9.2. All of them use DSL or cable Internet access. The problem is that from time to time their ISPs change the IPs of the modem, which prevents me to remotely administer the machines without asking some of the people there to check what is their current external IP by checking http://www.whatismyip.com/ or the config of the modem.
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Cheers Sunny
Why not have them register with dnydns.org (it's free) and then you could always use the same name to access their computers.
I also use ddclient to check for an IP address change every 5 minutes so I never have to go more than 5 minutes without the ability to connect. Imagine losing the remote connection and having to wait a hour to connect again if the friend isn't around to tell you the new IP address.
-- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998
Thanks Ken. ddcleint is not an option for me, as no DNS is involved. Anyway, I think that Brad's solution will work. And I'll decide about the interval. Actually, if the friend is not there, then he/she does not need the puter, and I can wait lets say 30 min :). Whatever, I guess you are right, 30 min will be real PITA, so maybe 5 or 10 ... Cheers Sunny
On Tue, 2005-06-14 at 13:47 -0500, Sunny wrote:
On 6/14/05, Ken Schneider
wrote: On Tue, 2005-06-14 at 14:10 -0400, Ken Schneider wrote:
Why not have them register with dnydns.org (it's free) and then you could always use the same name to access their computers.
I also use ddclient to check for an IP address change every 5 minutes so I never have to go more than 5 minutes without the ability to connect. Imagine losing the remote connection and having to wait a hour to connect again if the friend isn't around to tell you the new IP address.
Thanks Ken.
ddcleint is not an option for me, as no DNS is involved. Anyway, I think that Brad's solution will work. And I'll decide about the interval. Actually, if the friend is not there, then he/she does not need the puter, and I can wait lets say 30 min :). Whatever, I guess you are right, 30 min will be real PITA, so maybe 5 or 10 ...
Cheers Sunny
ddclient ties in with dyndns.org to keep an updated IP address. -- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998 "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners." -Ernst Jan Plugge
On Tuesday 14 June 2005 14:24, Ken Schneider wrote:
Why not have them register with dnydns.org (it's free) and then you could always use the same name to access their computers.
I also use ddclient to check for an IP address change every 5 minutes so I never have to go more than 5 minutes without the ability to connect. Imagine losing the remote connection and having to wait a hour to connect again if the friend isn't around to tell you the new IP address.
How should this be done if the computer is behind a router? In other words, it would be the router's IP that is actually changing, right? So can the computer behind the router detect that the router's IP changed? Thank you. Bryan ******************************************************** Powered by SuSE Linux 9.2 Professional KDE 3.3.0 KMail 1.7.1 This is a Microsoft-free computer Bryan S. Tyson bryantyson@earthlink.net ********************************************************
On 6/14/05, Bryan Tyson
How should this be done if the computer is behind a router? In other words, it would be the router's IP that is actually changing, right? So can the computer behind the router detect that the router's IP changed?
Thank you.
Bryan
Looks like (reading the docs) ddclient can use a web detect - i.e. hiting some web address which in response returns the IP. Something similar to the approach we were discussing earlier with Brad. So, now the choice is mine (I love this) - I can use such a tool and dyndns, or I can do it myself using the script Brad provided and I changed. Or ... a different approach will be to setup a server which listens for my machines, and writes down their IPs. Looks like a overwork though :) Cheers Sunny
* Bryan Tyson
How should this be done if the computer is behind a router? In other words, it would be the router's IP that is actually changing, right? So can the computer behind the router detect that the router's IP changed?
No, the router's IP should not change, but you will have to go *outside* the router to get your changed IP, ie: curl www.whatismyip.com |grep Title|awk -F ':: ' '{print $1}' note: this is cludged together from previous examples provided here. I do not know awk to get *only* the IP, but this works on my box thru the router. -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org HOG # US1244711 Photo Album: http://wahoo.no-ip.org/gallery
On Tue, 2005-06-14 at 20:26 -0400, Bryan Tyson wrote:
On Tuesday 14 June 2005 14:24, Ken Schneider wrote:
Why not have them register with dnydns.org (it's free) and then you could always use the same name to access their computers.
I also use ddclient to check for an IP address change every 5 minutes so I never have to go more than 5 minutes without the ability to connect. Imagine losing the remote connection and having to wait a hour to connect again if the friend isn't around to tell you the new IP address.
How should this be done if the computer is behind a router? In other words, it would be the router's IP that is actually changing, right? So can the computer behind the router detect that the router's IP changed?
Thank you.
Bryan Yes, that is what ddclient does. It checks the address on the wan interface and if it is different it performs an update at dyndns.org
-- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998 "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners." -Ernst Jan Plugge
See the ddclient and ez-ipupdate packages.
participants (9)
-
Brad Bendily
-
Bruce Marshall
-
Bryan Tyson
-
Gary Gapinski
-
James Knott
-
Ken Schneider
-
Patrick Shanahan
-
Sunny
-
suse_gasjr4wd@mac.com