Post

Name.com auto-update dns

Name.com auto-update dns

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

cd /home/shells &&

myip=$(curl -s "http://myip.com")
oldip=$(cat my_old_ip)
if [[ $oldip == $myip ]];then
echo 'the same ip'

exit 0

else
curl -u 'username:token' 'https://api.name.com/v4/domains/666666.xyz/records/97348949873' -X PUT --data '{"host":"q","fqdn":"666666.xyz","type":"AAAA","answer":"'$myip'","ttl":300}' &&

echo $myip > my_old_ip

fi

#: curl -u ‘username:token’ ‘https://api.name.com/v4/domains/666666.xyz/records/ get ID。

This post is licensed under CC BY 4.0 by the author.