# ddns **Repository Path**: cn148/ddns ## Basic Information - **Project Name**: ddns - **Description**: ddns.py 是基于 [DNSPod](http://www.dnspod.cn/docs/records.html#dns) 服务的动态 DNS 脚本,用于检测 IP 变化并更新至 DNSPod,支持多域名解析。支持 Linux 设备,包括树莓派([Raspberry Pi](https://www.raspberrypi.org/))。 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2018-01-18 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ddns.py ``` @author tinko @version 0.0.4 ``` ddns.py 是基于 [DNSPod](http://www.dnspod.cn/docs/records.html#dns) 服务的动态 DNS 脚本,用于检测 IP 变化并更新至 DNSPod,支持多域名解析。支持 Linux 设备,包括树莓派([Raspberry Pi](https://www.raspberrypi.org/))。 # Prerequisites 1. python # Installation 安装 [git](https://git-scm.com/) 客户端,通过本命令获取 ddns.py
git clone https://gitee.com/tdg/ddns.git ddns然后到 ddns 目录下新建 ```conf.json``` 文件,根据您的 DNSPod 设置,填入以下内容:
{
"id": <your_api_token_id>,
"token": <your_api_token>,
"domain": <your_domain>,
"sub_domains": [
{
"name": <your_first_sub_domain_name>,
"domain_id": <your_domain_id>,
"record_id": <your_record_id>
},
{
"name": <your_second_sub_domain_name>,
"domain_id": <your_domain_id>,
"record_id": <your_record_id>
}
]
}
获取你的domain_id
curl -X POST https://dnsapi.cn/Domain.List -d 'login_token=LOGIN_TOKEN&format=json'获取你的record_id
curl -X POST https://dnsapi.cn/Record.List -d 'login_token=LOGIN_TOKEN&format=json&domain_id=YOUR_DOMAIN_ID'最后设置 crontab 定时任务 每隔30分钟运行一次,以便更新DNS记录:
sudo crontab -e /30 * * * * python /home/pi/ddns/ddns.py