From owner-freebsd-questions Sun Dec 9 8:50:51 2001 Delivered-To: freebsd-questions@freebsd.org Received: from sage-american.com (sage-american.com [216.122.141.44]) by hub.freebsd.org (Postfix) with ESMTP id DD27E37B419 for ; Sun, 9 Dec 2001 08:50:44 -0800 (PST) Received: from SAGEONE (adsl-64-219-20-12.dsl.crchtx.swbell.net [64.219.20.12]) by sage-american.com (8.9.3/8.9.3) with SMTP id KAA08447; Sun, 9 Dec 2001 10:50:33 -0600 (CST) Message-Id: <3.0.5.32.20011209105037.0101cb38@mail.sage-american.com> X-Sender: jacks@mail.sage-american.com X-Mailer: QUALCOMM Windows Eudora Pro Version 3.0.5 (32) Date: Sun, 09 Dec 2001 10:50:37 -0600 To: "Oliver, Michael W." , freebsd-questions@freebsd.org From: jacks@sage-american.com Subject: RE: Scripting help Cc: "Oliver, Michael W." In-Reply-To: <1DA741CA6767A144BAA4F10012536C27A922@LKLDDC01.GARGANTUAN.C OM> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Thanks Michael, will work on it.... At 11:32 AM 12.9.2001 -0500, Oliver, Michael W. wrote: >Jack, > >Well, this will be my first script written from scratch, so please be kind >if I dork it up! Try this: > > > > > > >#!/bin/sh > >while [ 1 ] >do > > LAST_KNOWN_IP=`cat last_known_ip_file` > CURRENT_IP=`ifconfig tun0 | grep inet | awk ' { print $2; } '` > > if [ -z "$LAST_KNOWN_IP"] > then > # run your dns ping program here using $CURRENT_IP > echo $CURRENT_IP >last_known_ip_file > continue > fi > > if [ "$LAST_KNOWN_IP" = "$CURRENT_IP" ] > then > sleep 30 > continue > else > # run your dns ping program here using $CURRENT_IP > echo $CURRENT_IP >last_known_ip_file > fi > >done > >EOF > > > > > > > > >Please let me know how it turns out ;-) > >=========== >Michael Oliver > > > > > > > > > > > >> -----Original Message----- >> From: jacks@sage-american.com [mailto:jacks@sage-american.com] >> Sent: Sunday, December 09, 2001 11:02 AM >> To: freebsd-questions@freebsd.org >> Subject: Scripting help >> >> >> I have just set up an experimental FBSD 4.4-STABLE server >> using DSL with >> dynamic ip. Using ZoneEdit DNS services, the DNS can be >> updated with a cron >> script to still point to the proper name. I'm doing that now >> using cron to >> run the update script every 8 hours (the connection usually >> runs for weeks >> at a time without disconnect). >> >> However, I had rather have a script that runs every so often >> (xminutes) and >> doesn't bother the DNS server unless and ONLY if a changed in >> the dynamic >> IP has occured as a result of disconnect/reconnect. Here are >> the functions >> I see needed, but scripting language is not yet a decent >> skill of mine. I >> suspect others using dynamic IPs have this same need: Any guidence >> appreciated once again. (I've looked at the ipcheck that uses >> Python, but >> rather not go that route if possible to do the simple >> approach below). >> >> BEGIN (my crude) SCRIPT: >> #!/bin/sh >> PATH=/usr/local/bin:/usr/bin:/bin >> ## This script would be run by cron every x_minutes >> ## (files needed: "last_known_ip" and "my_current_ip") >> ## Contents of last_known_ip (placed there manually at for >> first output >> ## by running ifconfig tun0 > last_known_ip >> >> tun0: flags=8051 mtu 1492 >> inet 64.xxx.xx.20 --> 64.xxx.xx.254 netmask 0xffffffff >> Opened by PID 149 >> >> ## Run update to my_current_ip file >> # function: ifconfig tun0 > my_current_ip >> >> ##.... so the "my_current_ip" file would contain output of: >> tun0: flags=8051 mtu 1492 >> inet 64.xxx.xx.20 --> 64.xxx.xx.254 netmask 0xffffffff >> Opened by PID 149 >> >> ## Now make comparison to see if dynamic ip has changed and >> update DNS if >> changed. >> # function: look in my_current_ip and find the current ip >> (64.xxx.xx.20) >> # function: look in last_known_ip file and find ip (64.xxx.xx.66) >> # function: if not same, then run DNS_ping_program to update >> (ping command >> here) >> ## If change detected, update comparison file >> # function: ifconfig tun0 > last_known_ip >> # function: if same ip, then do nothing >> END OF SCRIPT >> >> The above may be a crude approach, but best way I can define >> the job for >> now.... >> >> Best regards, >> Jack L. Stone, >> Server Admin >> >> Sage-American >> http://www.sage-american.com >> jacks@sage-american.com >> >> To Unsubscribe: send mail to majordomo@FreeBSD.org >> with "unsubscribe freebsd-questions" in the body of the message >> > > Best regards, Jack L. Stone, Server Admin Sage-American http://www.sage-american.com jacks@sage-american.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message