Last active
January 21, 2020 21:02
-
-
Save dominikholler/aec112a2ee05288588895120f41189d7 to your computer and use it in GitHub Desktop.
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/bash | |
# in /etc/ddclient.conf: | |
# postscript=/opt/scripts/update_ipv6.sh | |
function update_domain() { | |
DOMAIN=$1 | |
USERNAME=$2 | |
PASSWORD=$3 | |
SERVER=$4 | |
#DEVICE="dev eth0" | |
URL=https://$SERVER/nic/update | |
FORCE_GET="-X GET -G" | |
DNS_SERVER=@2606:4700:4700::1111 # bypass DNS rebinding protection | |
VERBOSITY="-s -S" | |
LOGGER="logger -t $(basename $0 .sh)" | |
ACTUAL_ADDRESS=$(dig $DOMAIN AAAA $DNS_SERVER +short) | |
TARGET_ADDRESS=$(\ | |
/sbin/ip -6 -o addr show $DEVICE scope global dynamic -deprecated -temporary \ | |
| grep -v " inet6 f[cd]" | head -n 1 | cut -d " " -f 7 | cut -d / -f 1) | |
[ "$ACTUAL_ADDRESS" = "$TARGET_ADDRESS" ] || \ | |
curl $VERBOSITY $FORCE_GET \ | |
--user $USERNAME:$PASSWORD \ | |
--data-urlencode hostname=$DOMAIN \ | |
--data-urlencode myip=$TARGET_ADDRESS $URL | \ | |
xargs echo updating $DOMAIN from $ACTUAL_ADDRESS to $TARGET_ADDRESS: | \ | |
$LOGGER | |
} | |
update_domain xxx.ath.cx myusername password members.dyndns.org | |
update_domain something.net otherusername otherpassword dyndns.strato.com | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
similar: