-
-
Save Rutenioum/903e7b3a9d0229697286dcfde79f3beb to your computer and use it in GitHub Desktop.
he.net ddns auto update
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 | |
nic="eth0" | |
export LastIP=`/bin/cat /var/log/ipv6addr` | |
export NowIP=`ip -o -6 addr show dev $nic scope global |head -n 1 | /bin/sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d'` | |
password="you password" | |
hostname="nas.d.youdomain.com" | |
if [ -z "$NowIP" ] | |
then | |
echo `date` 没有 IPV6 !退出!>> /var/log/dns.he.log | |
exit | |
fi | |
if [ "$NowIP" != "$LastIP" ] | |
then | |
echo -n "$NowIP" > /var/log/ipv6addr | |
echo `date` "IP 改变,更新 Dns..." >> /var/log/dns.he.log | |
echo -n `date` [ >> /var/log/dns.he.log | |
# 下面一行代码是更新 dns,请根据自己情况修改 | |
curl -6 --interface ${nic} -k "https://dyn.dns.he.net/nic/update" -d "hostname=${hostname}" -d "password=${password}" >> /var/log/dns.he.log | |
echo ] >> /var/log/dns.he.log | |
else | |
echo `date` "IP 没有变化..." >> /var/log/dns.he.log | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment