Skip to content

Instantly share code, notes, and snippets.

@cuihaoleo
Created October 11, 2017 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuihaoleo/9b4fd1ff9c89eb27dcd4e666b3656ef1 to your computer and use it in GitHub Desktop.
Save cuihaoleo/9b4fd1ff9c89eb27dcd4e666b3656ef1 to your computer and use it in GitHub Desktop.
#!/bin/bash
DOMAIN=$1
KEY=$2
IPV4=$(ip route get 1 | grep -Po '(?<=src )[^ ]+')
IPV6=$(ip route get 2001:: | grep -Po '(?<=src )[^ ]+')
if [[ -n $IPv4 ]]; then
echo "Update IPv4: $IPV4"
curl -q "https://dyn.dns.he.net/nic/update" \
-d "hostname=$DOMAIN" \
-d "password=$KEY" \
-d "myip=$IPV4" \
--connect-timeout 2000
echo
fi
if [[ -n $IPv6 ]]; then
echo "Update IPv6: $IPV6"
curl -q "https://dyn.dns.he.net/nic/update" \
-d "hostname=$DOMAIN" \
-d "password=$KEY" \
-d "myip=$IPV6" \
--connect-timeout 2000
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment