There are ports that do this with more features, but I thought others
might like to do it in base with no added software. I've been using this
script since 4.2 and it works OK:

#!/bin/ksh

# 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 ]
then
  #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:p...@members.dyndns.org/nic/update?hostname=host.xxx&myip=$ip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG";
fi

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

Reply via email to