适用群晖需要设置ipv6的ddns时,可以适用下面的脚本定时更新解析地址(计划任务)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/bin/bash
noip_user="example@sina.com"
noip_pass="xxxxxxx"
noip_domain='example.ddns.net'
noip_url='https://dynupdate.no-ip.com/nic/update'
ipv6=`ip addr show eth0 | grep "inet6.*global" | awk '{print $2}' | awk -F"/" '{print $1}'`
current_ipv6=`nslookup -query=AAAA $noip_domain 2>&1`
current_ipv6=`echo "$current_ipv6" | grep 'Address: ' | tail -n1 | awk '{print $NF}'`
echo '-----------------' $ipv6
echo '-----------------' $current_ipv6
noip_data="?hostname=$noip_domain&myip=$ipv6"
noip_head=$(echo $noip_user:$noip_pass | base64)
if [ "$ipv6" = "$current_ipv6" ]
then
echo '-----------------' "Skipping"
else
curl -H "Authorization: Basic $noip_head" -s "$noip_url$noip_data"
echo '-----------------' "Updated record $ipv6"
fi
|