Update ddclient

An older script that I use on OpenBSD to update ddclient hostnames. The script should run with minor modifications on Linux.

#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin

IPFILE=/root/scripts/ipcheck.ip
INTF=tun0
MAILRCPT="yourmail"
MAILSUBJECT="DDclient update"

IP=`ifconfig $INTF | grep "inet " | grep -v inet6 | awk '{print $2}' |
sed 's/addr://'`

if [ -f $IPFILE ]; then
 OLDIP="`cat $IPFILE`"
fi

if [ "$IP" != "$OLDIP" ]; then
 echo $IP > $IPFILE
 /usr/bin/logger -t ipcheck_ddclient new IP address -- changed to $IP
 /sbin/ifconfig -a | mail -s $MAILSUBJECT $MAILRCPT
 /usr/local/sbin/ddclient -daemon=0 -syslog -use=ip -ip=$IP
fi

If you are unable to get your public IP from a local interface then you can use dyndns.org.

wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

One thought on “Update ddclient

  1. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment.

    Is there any way you can remove people from that service?
    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *