Last active
July 18, 2022 18:55
-
-
Save xnumad/65f0a9227c32888fb6e0056896cc8e9a to your computer and use it in GitHub Desktop.
IPv6 Dynamic DNS shell script for nsupdate.info derived from https://www.krausmueller.de/en/2017/07/04/dynamic-dns-client-for-ipv6/
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 | |
#Source: https://www.krausmueller.de/en/2017/07/04/dynamic-dns-client-for-ipv6/ | |
HOSTNAME="" | |
PASSWORD="token" | |
USER=HOSTNAME | |
CACHE_FILE="/tmp/update_ipv6_cache" | |
while getopts ":d" opt; do | |
case $opt in | |
d) DEBUG=1;; | |
esac | |
done | |
IPV6=$(ip addr show eth0 | grep 'scope global dynamic' | grep -Po 'inet6 \K[0-9a-fA-F:]+' | grep -v fd00 | tail -n 1) | |
URL="https://ipv6.nsupdate.info/nic/update?myip=$IPV6" | |
if [ -f $CACHE_FILE ]; then | |
IPV6_CACHE=$(cat $CACHE_FILE) | |
else | |
IPV6_CACHE="" | |
fi | |
if [[ $IPV6 == "$IPV6_CACHE" ]]; then | |
if [[ $DEBUG -eq 1 ]]; then | |
echo "IP not changed" | |
fi | |
exit | |
else | |
echo "$IPV6" > $CACHE_FILE | |
if [[ $DEBUG -eq 1 ]]; then | |
echo wget -q -O - "$URL" --http-user=$USER --http-password=$PASSWORD | |
wget -q -O - "$URL" --http-user=$USER --http-password=$PASSWORD | |
else | |
wget -q -O - "$URL" --http-user=$USER --http-password=$PASSWORD >/dev/null 2>&1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rather use dyndnsc or something else.