John Hebert <[EMAIL PROTECTED]> writes: hmm. openbsd has /sbin/dhclient-script which is called with dhclient renews the IP lease. I just hooked into that adding a few lines to email my yahoo account with the new info if an actual change in the IP address is detected (or the box is rebooted) . It also ssh'd (using a key and special account established for the purpose) to a remote dns server handling my hostname and used sudo to update the domain and reload. the record for house.scottharney.com has a 30 minute ttl so this is my sort of homebrew dyndns. Since my IP has never actually changed, I haven't had to worry about this too much. Though it has been tested successfully with reboots of my firewall.
Just skimming the man page, it looks like dhcpcd (which is your typical linux dhcp client) can call a script on renewals as well so it's probably relatively easy to do the same sort of thing on linux. I'd suspect that's what dyndns.org scripts do. Or they just cache info in /var/db/dhcpd.lease and watch for updates either via cron or a continually running script with a sleep() interval. > Nifty script! Thanks, Adam. I've been wanting a script to do just this for a > while. I kept looking for some low level C library call to detect the > current IP instead of just making it work. :) > > Does anybody know of such a C network library call, BTW? > > Thanks, > John Hebert > > -----Original Message----- > From: Adam J. Melancon > To: [email protected] > Sent: 10/14/03 11:05 AM > Subject: Re: [brlug-general] Email - Clear Text - help??? > > I had a dynamic dns service at one time, but now I use a script to tell > me > if my ip has changed. It runs about ever 5 minutes using cron. > > [EMAIL PROTECTED] bin]# cat checkip.sh > #!/bin/bash > # I have this program running in /etc/crontab with the following > configuration: > # * * * * * root /usr/local/bin/newip > # > date=`date` > > ifconfig eth0 | grep "inet " | cut -f12 -d" " > /usr/local/bin/.newip > > if diff /usr/local/bin/.newip /usr/local/bin/.currentip; > then > > exit 0; > > else > cat /usr/local/bin/.newip > /usr/local/bin/.currentip; > cat /usr/local/bin/.currentip > /usr/local/bin/.report > date >> /usr/local/bin/.report > mail -s "New IP on $date"[EMAIL PROTECTED] < > /usr/local/bin/.report; > echo "different ip" > rm -f /usr/local/bin/.report > exit 0 > fi > [EMAIL PROTECTED] bin]# > > > > Adam J. Melancon > > _________________________________________________________________ > See when your friends are online with MSN Messenger 6.0. Download it now > > FREE! http://msnmessenger-download.com > > > _______________________________________________ > General mailing list > [email protected] > http://brlug.net/mailman/listinfo/general_brlug.net > > _______________________________________________ > General mailing list > [email protected] > http://brlug.net/mailman/listinfo/general_brlug.net > -- Scott Harney<[EMAIL PROTECTED]> "...and one script to rule them all." gpg key fingerprint=7125 0BD3 8EC4 08D7 321D CEE9 F024 7DA6 0BC7 94E5
