#Change your Alibaba SK in the quotation marks below. To put it bluntly, these are the account and passwordaliddnsipv6_sk="Access Key Secret"#Change the following quotation marks into the prefix of the domain name you want to resolve. If it is the root domain name, fill in it directly@aliddnsipv6_name1="area"#Change the following quotation marks to the main domain name you want to resolve, for example: baidu comaliddnsipv6_domain="domain.cn"#Change the parsing switching time you need in the quotation marks below. Alibaba defaults to a maximum of 600 seconds, which can be reduced by spending moneyaliddnsipv6_ttl="600"#Judge whether it contains @ because the resolution containing @ is directly reported to xxx COM, instead of blindly reporting as @ xxx. comif["$aliddnsipv6_name1"="@"]thenaliddnsipv6_name=$aliddnsipv6_domainelsealiddnsipv6_name=$aliddnsipv6_name1.$aliddnsipv6_domainfi#Make time and record good momentsecho "Now Time:$(date)"#Here are two ways to get the IPv6 address of your local machine, so that one can hang up and the other can be backed up. Of course, you can also use the if statement to judge. If the first one doesnt work, use the second...#If you want to resolve IPv4, put the following v6 ident. Replace me with v4 ident. me#v6.ident. If me fails, switch to IPv6 directly ip. sb# ipv6=`curl -sL --connect-timeout 3 v6.ident.me` # if [ "$ipv6" = "" ]# then# ipv6=$(ip -o addr show |grep -v deprecated|grep inet6 [^f:]|sed -nr s#^.+? +inet6 ([a-f0-9:]+)/.+? scope global .*? valid_lft ([0-9]+sec) .*#2 1#p|grep ff:fe|sort -nr|head -n1|cut -d -f2)# Print out the current local IPv6 address. What did you do to compare the programecho "LocalHost IP:$ipv6"#The following is to get the IPv6 address currently resolved by Alibaba for you. If you want to resolve IPv4, replace AAAA with a########It is recommended to use the default one, because after you update DNS, dns9 hichina. COM is effective immediately#########To resolve IPv4, you need to delete &type=AAA#current_ipv6=`nslookup -query=AAAA $aliddnsipv6_name dns9.hichina.com 2>&1 | grep Address: | tail -n1 | awk {print $NF}`current_ipv6=$(curl -sL--connect-timeout3"tdns.cupker.cn/d?dn=$aliddnsipv6_name&type=AAAA")# tdns.cupker.cn bind tdns.cupker.cn#$(ip -o addr show |grep -v deprecated|grep inet6 [^f:]|sed -nr s#^.+? +inet6 ([a-f0-9:]+)/.+? scope global .*? valid_lft ([0-9]+sec) .*#2 1#p|grep ff:fe|sort -nr|head -n1|cut -d -f2)# $(curl -sL --connect-timeout 3 "119.29.29.29/d?dn=$aliddnsipv6_name&type=AAAA")#Print it again for you to see clearlyecho "Current Alibaba resolution ip:$current_ipv6"#If the local IPv6 and Alibaba resolve the same, Ill passif["$ipv6"="$current_ipv6"]thenecho "You see, the IP hasnt changed and doesnt need to be updated. Im leaving..."exit#If its different, Ill start updating itelseunsetaliddnsipv6_record_idfi#The timestamp format should be correcttimestamp=$(date-u"+%Y-%m-%dT%H%%3A%M%%3A%SZ")#The following are Alibaba related, all of which are required in various formats, as well as obtaining recordid and so on. Lets jump to the update record and go downurlencode(){# urlencode <string>out=""whileread-n1cdocase$cin[a-zA-Z0-9._-])out="$out$c";;*)out="$out$(printf%%%02X"$c")";;esacdoneecho -n$out}enc(){echo -n"$1"|urlencode}send_request(){localargs="AccessKeyId=$aliddnsipv6_ak&Action=$1&Format=json&$2&Version=2015-01-09"localhash=$(echo -n"GET&%2F&$(enc"$args")"|openssldgst-sha1-hmac"$aliddnsipv6_sk&"-binary|opensslbase64)curl -s"http://alidns.aliyuncs.com/?$args&Signature=$(enc"$hash")"}get_recordid(){grep-Eo"RecordId":"[0-9]+"|cut-d:-f2|tr-d"}#Here ----------- the following type=aaaa is the only difference between updating IPv6 and IPv4. The rest of the update codes are the same, so it can be understood in this way -- line feed#For example, the following can be changed from AAAA to aquery_recordid(){send_request"DescribeSubDomainRecords""SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&SubDomain=$aliddnsipv6_name&Timestamp=$timestamp&Type=AAAA"}update_record(){send_request"UpdateDomainRecord""RR=$aliddnsipv6_name1&RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=$aliddnsipv6_ttl&Timestamp=$timestamp&Type=AAAA&Value=$(enc$ipv6)"}add_record(){send_request"AddDomainRecord&DomainName=$aliddnsipv6_domain""RR=$aliddnsipv6_name1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=$aliddnsipv6_ttl&Timestamp=$timestamp&Type=AAAA&Value=$(enc$ipv6)"}if["$aliddnsipv6_record_id"=""]thenaliddnsipv6_record_id=$(query_recordid|get_recordid)fiif["$aliddnsipv6_record_id"=""]thenaliddnsipv6_record_id=$(add_record|get_recordid)echo "New parsing has been added$aliddnsipv6_name $ipv6 $aliddnsipv6_record_id"elseupdate_record$aliddnsipv6_record_idecho "New parsing has been added $aliddnsipv6_name as $ipv6"fi
IPIP.NETIPCN搜狐IP138Ping, mtr, dig and TCP port check from multiple locationsicanhazip.comComprehensive IP address data, IP geolocation API and database – IPinfo.ioIP Address Lookup / IPv4 / IPv6 – IP.SB方便通过命令查看的