简介
虽然许多路由器都有提供免费的域名解析,但是TTL的时间过长,大部分超过半个小时以上。DNSpod 可以通过API进行域名的解析,我们正好可以通过python进行ip记录的修改。
启动项service 脚本: https://gist.githubusercontent.com/billryan/239778f0821937939c8c140bdddd6840/raw/c76b52af0e8e8e50b5ee1b6a012e43e9f9dc39b4/dnspod-ddns.service
ip获取上传: https://gist.githubusercontent.com/billryan/239778f0821937939c8c140bdddd6840/raw/c76b52af0e8e8e50b5ee1b6a012e43e9f9dc39b4/dnspod_ddns.py
安装
替换上你的ID, Token, domain, sub_domain 就可以运行了。(ID,Token) 可以从 API 鉴权方式升级为 Token 获得。 脚本会在后台一直运行,初始化时会根据 sub_domain 查询是否已经创建,每隔30秒检查一遍IP,如果修改了就更新IP。
以 Archlinux 为例,按照如下步骤操作即可设置开机启动这个 DDNS 服务。
Archlinux 以下
sudo wget -O /usr/local/bin/dnspod_ddns.py https://gist.githubusercontent.com/billryan/239778f0821937939c8c140bdddd6840/raw/c76b52af0e8e8e50b5ee1b6a012e43e9f9dc39b4/dnspod_ddns.py sudo chmod +x /usr/local/bin/dnspod_ddns.py sudo wget -O /etc/systemd/system/dnspod-ddns.service https://gist.githubusercontent.com/billryan/239778f0821937939c8c140bdddd6840/raw/c76b52af0e8e8e50b5ee1b6a012e43e9f9dc39b4/dnspod-ddns.service sudo systemctl start dnspod-ddns sudo systemctl enable dnspod-ddns
|
参考
DNSPod DDNS Python Script
家用服务器之 DDNS