Skip to main content

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

  1. 下载所有文件到某个地方, 例如: /opt/aliddns

  2. ddns.conf.example 重命名为 ddns.conf

  3. 创建一个 cron 任务,定时执行 python ddns.py, 例如:

    */5 * * * * cd /opt/aliddns && /usr/bin/python ddns.py
    
  4. 确保 cron 用户可以访问 ddns.conf

2. 使用 SystemD

  1. 下载所有文件到某个地方, 例如: /root/tools/aliddns

  2. ddns.conf.example 重命名为 ddns.conf

  3. 复制 ddns.timerddns.service/usr/lib/systemd/system

  4. 执行:

    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

开始使用

  1. 在阿里云控制台手动创建 DNS 解析条目,例如: blog.guanxigo.com
  2. 您可以在阿里云服务器上为该条目留下任何IP地址,如 192.168.0.1
  3. 确保所有必需的选项都正确输入到 ddns.conf
  4. 启用您想要使用的功能
  5. 确保 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aliddns2-0.1.1-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

aliddns2-0.1.1-py2-none-any.whl (23.1 kB view details)

Uploaded Python 2

File details

Details for the file aliddns2-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aliddns2-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for aliddns2-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8044b95b4c3d36086de079a437d80eff6bbab2069a26d0a012ad9d2b74f71b8f
MD5 8af63706e0ed5a22b9701e84b070343c
BLAKE2b-256 c406d763c7b7676e8420c40e3407825694151bd207d681d61f84038a5348aa22

See more details on using hashes here.

File details

Details for the file aliddns2-0.1.1-py2-none-any.whl.

File metadata

  • Download URL: aliddns2-0.1.1-py2-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for aliddns2-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 9d7c5c2d5dc7d6c3a4bf143d703059a2ed65b07e6779c59558b2472fd770cee4
MD5 586e9e45f47ecd231be8df716115fc49
BLAKE2b-256 bc1ef7edaf3197d7470f0c141c17a7fa777dbadc077dcc5d9668556a93cf481b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page