DDNS
DDNS
My home network doesn’t get a public IPv4 (my ISP uses DS-Lite) and even my public IPv6 changes daily, so to be able to reach my server in my home network, I need to use Dynamic DNS.
- My registrar is Njalla. Your registrar will use a differently formatted URL to update the IP, change the script accordingly.
- My server gets a /128 IPv6 via DHCP. Yours may get a /64 address or something else, change the script accordingly.
ddns.sh
#!/bin/bash
## This script will update a dynamic DNS entry in Njal.la if the current interface ip is different to domains ip (IPv6 only!)
# Enter domain and key
domain=
key=
current=$(dig +short $domain AAAA)
echo Current DNS response: $current
# We look for a public IPv6 with /128 CIDR
ip=$(ip a | sed -e's/^.*inet6 \(2[^ ]*\)\/128 scope global dynamic.*$/\1/;t;d')
echo Interface: $ip
if [ "$current" != "$ip" ]
then
echo Updating AAAA entry
curl "https://njal.la/update/?h=$domain&k=$key&aaaa=$ip"
fi