Created
October 11, 2017 12:17
-
-
Save cuihaoleo/9b4fd1ff9c89eb27dcd4e666b3656ef1 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 | |
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