Last active
May 1, 2019 00:22
-
-
Save skandragon/8b231fd559ab922f137d3ec33e3973fd to your computer and use it in GitHub Desktop.
openwrt manual ddns update script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# update via ddns | |
# /etc/hotplug.d/iface/30-skan-ddns | |
[ "$INTERFACE" != "wan" ] && ( [ "$ACTION" != "ifup" ] || [ "$ACTION" != "update" ] ) && exit 0 | |
user='username-here' | |
password='password-here' | |
token="hmac-md5:$user:$password" | |
host='rtr' | |
zone='home-okc.flame.org' | |
server='dns01.flame.org' | |
ipaddr=`ifconfig eth1 | grep 'inet addr:' | awk '{ print $2}' | cut -f2 -d:` | |
ipaddr6=`ifconfig eth1 | grep 'inet6 addr:' | grep Global | awk '{ print $3 }' | cut -f1 -d/` | |
if [ -z "$ipaddr$ipaddr6" ] ; then | |
echo "Not updating as we have no external addresses" | |
exit 1 | |
fi | |
rm -f /tmp/ddns.$$ | |
echo >> /tmp/ddns.$$ server $server | |
echo >> /tmp/ddns.$$ zone $zone. | |
if [ -n "$ipaddr" ] ; then | |
echo >> /tmp/ddns.$$ update delete $host.$zone. A | |
echo >> /tmp/ddns.$$ update add $host.$zone. 86400 A $ipaddr | |
fi | |
if [ -n "$ipaddr6" ] ; then | |
echo >> /tmp/ddns.$$ update delete $host.$zone. AAAA | |
echo >> /tmp/ddns.$$ update add $host.$zone. 86400 AAAA $ipaddr6 | |
fi | |
echo >> /tmp/ddns.$$ show | |
echo >> /tmp/ddns.$$ send | |
cat /tmp/ddns.$$ | nsupdate -y $token -v | |
rm -f /tmp/ddns.$$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment