Date: Sun, 09 Dec 2001 10:50:37 -0600 From: jacks@sage-american.com To: "Oliver, Michael W." <oliver.michael@gargantuan.com>, freebsd-questions@freebsd.org Cc: "Oliver, Michael W." <oliver.michael@gargantuan.com> Subject: RE: Scripting help Message-ID: <3.0.5.32.20011209105037.0101cb38@mail.sage-american.com> In-Reply-To: <1DA741CA6767A144BAA4F10012536C27A922@LKLDDC01.GARGANTUAN.C OM>
next in thread | previous in thread | raw e-mail | index | archive | help
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<UP,POINTOPOINT,RUNNING,MULTICAST> 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<UP,POINTOPOINT,RUNNING,MULTICAST> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.5.32.20011209105037.0101cb38>
