Date: Sun, 09 Dec 2001 10:02:24 -0600 From: jacks@sage-american.com To: freebsd-questions@freebsd.org Subject: Scripting help Message-ID: <3.0.5.32.20011209100224.0101cb38@mail.sage-american.com>
next in thread | raw e-mail | index | archive | 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.5.32.20011209100224.0101cb38>