recently i started to use DynDNS service. to automatically manage IP changes on machine involved i wrote simple shell script. since it is on the router with OpenWRT installed, it includes IP-getting technique required there.

new feature is “-f” option to force IP updating. it is a good thing to do so from time to time, to prevent account removal after 30 days.

# metchod of getting current IP; this one's valid for OpenWRT/Backfire
IP="`ifconfig  eth0.1 | grep addr: | sed 's#^ *inet addr:##' | sed 's# .*##'`"
# get last set IP
touch "$LAST_IP_FILE"
# skip if not changed and not forced
[ "$1" != "-f" ] && [ "$LAST_IP" = "$IP" ] && exit 0
# update on change
wget -O /dev/null "http://$USER:$PASS@members.dyndns.org/nic/update?hostname=$DOMAIN&myip=$IP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" || exit $?
echo "$IP" > "$LAST_IP_FILE"
exit $?

script in raw (i.e. text) form can be obtained here: dyndns_update.

prjs/dyndns_update.txt · Last modified: 2021/06/15 20:09 (external edit)
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0