home Sandy, UT
Wednesday, 2017.11.22
04:20 MDT [GMT-7]
Brionews - Company Logo Condition: Partly Cloudy
Temperature: 4°C (39.2°F)
Barometer: 1029 mb and rising
Low Cost Affordable C C++ PHP mySQL Perl Programs Development

Update Your Dynamic IP

Apr. 12, 2010

This shell script is to update the dynamic IP address of your server on those free DNS hosts.
I found it online, would love to recognize credits if I knew who did it.
I had to adapt it to my needing. It runs pretty well on my OpenBSD.
Call the script whatever you want then just cron it.
It has been succesfully tested on www.dyndns.com/
then adapted again for www.no-ip.com/


# 20100405 - adapted from a script found online - $briosky$
# cron this script to update your servers dynamic ip @dyndns.org
# many variants are possible. Like using macro and passing them:
# user = user_name
# pass = your_pass
# host = hostname

lynx -dump http://checkip.dyndns.org:8245/ | awk '{print $4}' | \
  sed '/^$/d' > ip_dyndns-new.txt

ip=$(cat ip_dyndns-new.txt)

# here also there is alot to play around
# date >> ip_dyndns-date.txt
# cat ip_dyndns-old.txt >> ip_dyndns-history.txt

curl --insecure "https://user:pass@members.dyndns.org/nic/update? \ 
# variant: at the end of the previous line you can add
# curl bla-bla-bla 2>>ip_dyndns-response.txt
cp ip_dyndns-new.txt ip_dyndns-old.txt


Here I tried some servers at no-ip.com but the port 8245 does not answer, so I used the same server as above.

Here also there is to play
lynx -dump http://checkip.dyndns.org:8245/ | awk '{print $4}' | \
  sed '/^$/d' > ip_noip-new.txt
ip=$(cat ip_noip-new.txt)
#date >> ip_noip-date.txt
#cat ip_noip-old.txt >> ip_noip-history.txt
curl --insecure "https://<id>:<pass>@dynupdate.no-ip.com/nic/update?hostname= \
cp ip_noip-new.txt ip_noip-old.txt

original script

# Cron this script to run every X minutes. Written for OpenBSD.

# Get Current IP
lynx -dump http://checkip.dyndns.org:8245/ | awk '{print $4}' | \
  sed '/^$/d' > ip_new.txt

# compare new with old
diff ip_new.txt ip_old.txt

# if different, send update
if [ $? -ne 0 ]
  #echo "The IP has changed"
  ip=$(cat ip_new.txt)
  # Following two lines are optional. Log date of change and IP history.
  date >> ip_date.txt
  cat ip_old.txt >> ip_history.txt
  curl --insecure "https://user:pass@members.dyndns.org/nic/update?\

# Whether a change has occurred or not, overwrite old with new
cp ip_new.txt ip_old.txt

Have fun.

Vince Maggio, a.k.a. briosky

Last Updated on: Wednesday May 05, 2010 - 09:26:10 AM MDT