Skip to content

Instantly share code, notes, and snippets.

@qinghon
Last active December 19, 2023 03:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save qinghon/52773319a65cb9608ccf743b023fa99a to your computer and use it in GitHub Desktop.
Save qinghon/52773319a65cb9608ccf743b023fa99a to your computer and use it in GitHub Desktop.
he.net ddns auto update
#!/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