Why don't you just set the lease time to some absurdly large value so you never have to worry about it ever changing? Regards, jimmo On Wednesday 13 February 2002 18:35, Gordon Pritchard wrote:
Hi everyone:
I was happily SSH'ing into my home-PC, well aware that the first part of DHCP means "dynamic"... For quite a long time, my IP-address stayed the same, then yesterday, I couldn't get into my machine (from work). That prompted some thinking (always dangerous :-) ).
I thought I'd share what I did, and hope that it may help someone else, or stimulate an even better solution.
In a nutshell, I have my home-SuSE machine check the IP-address every hour. If it sees a change, then it mails me the new IP-address (to my work-email).
(Note: I read the man-page for dhcpcd, and it looks like there is a facility to run a script only when the DHCP-client status changes. This may be a better way to do things, rather than my cron approach. Nonetheless, my parsing and notification may still be useful, even if the trigger-event is different).
Without further ado, here is the bash-script:
#!/bin/bash
# ip_check.sh # Written by Gordon Pritchard. Feb. 12, 2002.
# The purpose of this script it to check (via cron) if my DHCP # assigned IP-address has changed. If not, do nothing. If yes, # mail me the new IP-address.
# Place this file in /etc/cron.hourly (SuSE system), and set the # owner/group to 'root'. Make sure it's executable.
# First, we'll get the current IP-address
/sbin/ifconfig eth0 | awk '/inet / {print $2}' > latest_ip
# See if our latest IP-address is the same as the previously # assigned IP-address. This works fine the first time this # script is run, and previous_ip doesn't exist.
if cmp -s latest_ip previous_ip then exit else cp latest_ip previous_ip mail -s "IP address change!" username@domain < latest_ip fi
# You've got mail :-)
-Gord
-- --------------------------------------- "Science has promised man power...But, as so often happens when people are seduced by promises of power, the price is servitude and impotence. Power is nothing if it is not the power to choose." Joseph Weizenbaum of MIT said in reference to Computers. --------------------------------------- The Great Linux-NT Debate: http://www.jimmo.com/Linux-NT_Debate/index.html --------------------------------------- NOTE: All messages sent to me in response to my posts to newsgroups or forums are subject to reposting.