From owner-freebsd-questions Sun Dec 9 8: 2:27 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 89B1137B417 for ; Sun, 9 Dec 2001 08:02:23 -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 KAA01162 for ; Sun, 9 Dec 2001 10:02:20 -0600 (CST) Message-Id: <3.0.5.32.20011209100224.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:02:24 -0600 To: freebsd-questions@freebsd.org From: jacks@sage-american.com Subject: Scripting help 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 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