On Fri, 19 Mar 2010 14:04:16 +0300 Vadim Zhukov <persg...@gmail.com> wrote:
> On 19 March 2010 c. 10:54:26 Duncan Patton a Campbell wrote: > > On Thu, 18 Mar 2010 21:52:28 -0400 > > > > "Brad Tilley" <b...@16systems.com> wrote: > > > There are ports that do this with more features, but I thought > > > others might like to do it in base with no added software. I've been > > > using this script since 4.2 and it works OK: > > > > > > #!/bin/ksh > > > > > > # Cron this script to run every X minutes. Written for OpenBSD. > > > > > > # Get Current IP > > > lynx -dump http://checkip.dyndns.org:8245/ | awk '{print $4}' | sed > > > '/^$/d' > ip_new.txt > > > > > > # compare new with old > > > diff ip_new.txt ip_old.txt > > > > > > # if different, send update > > > if [ $? -ne 0 ] > > > then > > > #echo "The IP has changed" > > > ip=$(cat ip_new.txt) > > > # Following two lines are optional. Log date of change and IP > > > history. date >> ip_date.txt > > > cat ip_old.txt >> ip_history.txt > > > curl --insecure > > > > > > "https://user:p...@members.dyndns.org/nic/update?hostname=host.xxx&m > > >yip=$ip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" fi > > > > > > # Whether a change has occurred or not, overwrite old with new > > > cp ip_new.txt ip_old.txt > > > > I've done a similar thing by hacking /sbin/dhclient-script to hook > > out from add_new_address(). I also suppress add_new_resolv_conf() > > and reupping from /etc/resolv.conf.save found in the main section. > > Suppressing update of resolv.conf is optional but it's useful > > to have the dns pointed at the nameserver for the domain and > > just leave it there. > > > > The hook out has to then call nsupdate with the newip address. > > The advantage to this approach is that is driven off the event > > of a new address by dhcp and not by polling. > > Possibly you could use dhclient.conf instead? > Yes, that's prob'ly the case. Sometime tho' an outright hack that doesn't get lost in configuration semantics is the best way to test out an idea, and that's all this was. This is actually using a generic hack that lets me impose prolog semantics on the event of address reassignment. Dhu > -- > Best wishes, > Vadim Zhukov > > A: Because it messes up the order in which people normally read text. > Q: Why is top-posting such a bad thing? > A: Top-posting. > Q: What is the most annoying thing in e-mail?