Recent Changes - Search:

PmWiki

pmwiki.org

edit SideBar

Tidbits

Automatically Updating Dynamic IP for Zoneedit DNS Server (dnsck.script)
Put this is in the Cron.Hourly making sure to update any path references

#!/bin/sh
# Determine my ip
lynx -dump "http://www.virtual-weltanschauung.com/t3.php" > /tmp/dns/myip1.log

# Determin current DNS of domain name
ping -c 1 www.virtual-weltanschauung.org | fgrep PING > /tmp/dns/dns.log

# Strip out whitespace of results of my ip result the remove extra line
sed 's/^[ \t]*//;s/[ \t]*$//' /tmp/dns/myip1.log > /tmp/dns/myip2a.log
sed '/^$/d' /tmp/dns/myip2a.log > /tmp/dns/myip2.log

# Use grep to find refined my ip addr in DNS result
grep -o -f /tmp/dns/myip2.log /tmp/dns/dns.log > /tmp/dns/dnsck.log

# compare the result of grep to the refined myIP
cmp /tmp/dns/myip2.log /tmp/dns/dnsck.log > /dev/null  # /dev/null buries the output of the "cmp" command.
# Also works with 'diff', i.e.,   diff $1 $2 > /dev/null (or so I read)

if [ $? -eq 0 ]        # Test exit status of "cmp" command.
then
  echo "File \"myip2.log\" is identical to file \"dnsck.log\"." >> /tmp/dns/test.log
else  
/tmp/dns/zoneed
fi

exit 0

The good thing about the multiple text files is that it gave me insight into which part was failing when it initially didn't work. I could just check each log file to see where the problem was.

See PHP section to get a page to return just your IP, but here it is also
Display IP Address

On a remote server to display the IP of the the requesting computer I used this
<?php
$ip = getenv('REMOTE_ADDR');
PRINT("$ip");
?>
You might be able to use http://checkip.dyndns.org:8245/ and clean it up a bit

Here is my script to update Zoneedit website DNS For My Home Domain
Put his in the folder that matches the dnsck.script

Create a shell script that has this: (A line for each domain name)(zoneed)

#!/bin/sh
lynx -source -auth=NAME:PASSWORD 'http://dynamic.zoneedit.com/auth/dynamic.html?host=www.virtual-weltanschauung.org'
lynx -source -auth=NAME:PASSWORD 'http://dynamic.zoneedit.com/auth/dynamic.html?host=harpo.virtual-weltanschauung.org'
lynx -source -auth=NAME:PASSWORD 'http://dynamic.zoneedit.com/auth/dynamic.html?host=virtual-weltanschauung.org' >> /tmp/dns/zone.log 

I'm sure any true Unix or Linux aficionado would be horrified by this, but until somebody shows me wonderful world of geeky purity I'll keep pfutzing around like this.


I put this all together and powered down my DSL modem for 30 minutes, after which it just grabbed a new IP.

I ran the above shell script and bingo it worked.

So I put it in the Cron.hourly folder. And we will see.


Here are my earlier notes as I worked through this problem:

sed 's/^[ \t]*//' ip2.log > ip4.log

clears the leading white space from one file and puts just the text in another file.


  1. delete BOTH leading and trailing whitespace from each line

sed 's/^[ \t]*//;s/[ \t]*$//'

From http://www.unixguide.net/unix/sedoneliner.shtml


Maybe this will help
(3) < Redirector Symbol
Syntax:
Linux-command < filename
To take input to Linux-command from file instead of key-board. For e.g. To take input for cat command give
$ cat < myfiles
from http://www.freeos.com/guides/lsst/index.html


And maybe grep will help (I could have them in two lines in one file).

http://pegasus.rutgers.edu/~elflord/unix/grep.html

And to match exactly an IP number from one file to another, maybe this will help

grep -o -f ip1.log ip2.log


Trouble with SED? After looking at this website http://www.student.northpark.edu/pemente/sed/sed1line.txt... How about this?

.

Edit - History - Print - Recent Changes - Search
Page last modified on April 24, 2006, at 05:07 AM