Aliyun DDNS client
Project description
AliDDNS
阿里云 Python DDNS 客户端 (https://github.com/kalixi/AliDDNS)
PS: Fork from https://github.com/rfancn/aliyun-ddns-client.
中文 | English
限制
本版本的 DDNS client只支持自动更新 “A” 类型 IPv4 地址的 DomainRecord。
其他类型不支持,因为它们需要以下值格式,而不是IP地址:
NS
,MX
,CNAME
类型 DomainRecord 需要域名格式值AAAA
类型 DomainRecord 需要 IPv6 地址格式的值SRV
类型 DomainRecord 需要名称.协议
格式的值显式URL
和隐式URL
需要 URL 格式值
先决条件
下面是 AliDDNS 需要的一些第三方 python 库,你可以通过 pip 或 easy_install 安装:
- requests
- netifaces
例如:
pip install requests netifaces
安装
1. 使用 cron
-
下载所有文件到某个地方, 例如:
/opt/aliddns
-
将
ddns.conf.example
重命名为ddns.conf
-
创建一个 cron 任务,定时执行
python ddns.py
, 例如:*/5 * * * * cd /opt/aliddns && /usr/bin/python ddns.py
-
确保 cron 用户可以访问
ddns.conf
2. 使用 SystemD
-
下载所有文件到某个地方, 例如:
/root/tools/aliddns
-
将
ddns.conf.example
重命名为ddns.conf
-
复制
ddns.timer
和ddns.service
到/usr/lib/systemd/system
-
执行:
root@local# systemctl daemon-reload root@local# systemctl start ddns.timer root@local# systemctl status ddns.timer -l
配置
/etc/ddns.conf
中需要设置的选项:
- access_id
- access_key
- domain
- sub_domain
可选的选项:
- type
[DEFAULT]
# access id obtains from aliyun
access_id =
# access key obtains from aliyun
access_key =
# it is not used at this moment, you can just ignore it
interval = 600
[DomainRecord1]
# domain name, like google.com
domain =
# subdomain name, like www, blog, bbs, *, @, ...
sub_domain =
# resolve type, 'A', 'AAAA'..., currently it only supports 'A'
type = A
[feature_public_ip_from_nic]
enable = false
interface = eth0
开始使用
- 在阿里云控制台手动创建 DNS 解析条目,例如:
blog.guanxigo.com
- 您可以在阿里云服务器上为该条目留下任何IP地址,如 192.168.0.1
- 确保所有必需的选项都正确输入到
ddns.conf
- 启用您想要使用的功能
- 确保
ddns.conf
对于设置cron作业的用户来说是可读的
注意: 只更新本地配置文件和阿里云服务器中定义的域记录。
常见问题
-
问: 为什么报错
The input parameter "Timestamp" that is mandatory for processing this request is not supplied.
? 答: 请检查参数 TimeStamp 的值是多少, 如果与正确时间相差较大,需要使用ntpdate
将系统时间同步到正确的时间。 -
问: 为什么报错
Failed to save the config value
? 答: 您需要确保当前的 cron 用户有权限写/etc/ddns.conf
文件。 -
问: 为什么报错
AttributeError: 'X509' object has no attribute '_x509'
? 答:PyOpenSSL 版本需要 >= 0.14,你可以尝试通过以下方法解决这个问题:sudo yum uninstall python-requests sudo pip uninstall pyopenssl cryptography requests sudo pip install requests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.