ddns


Nameddns JSON
Version 3.0.2 PyPI version JSON
download
home_pagehttps://ddns.newfuture.cc
Summaryautomatically update DNS records to dynamic local IP [自动更新DNS记录指向本地IP]
upload_time2024-06-13 12:25:23
maintainerNone
docs_urlNone
authorNewFuture
requires_python<4,>=2.5
licenseMIT
keywords ddns ipv6 ipv4 dns dnspod alidns cloudflare
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [DDNS](https://github.com/NewFuture/DDNS)

> 自动更新 DNS 解析 到本机 IP 地址,支持 ipv4 和 ipv6 以 本地(内网)IP 和 公网 IP。
> 代理模式,支持自动创建域名记录。

[![PyPI](https://img.shields.io/pypi/v/ddns.svg?label=DDNS&style=social)](https://pypi.org/project/ddns/)
[![Build Status](https://github.com/NewFuture/DDNS/actions/workflows/build.yml/badge.svg?event=push)](https://github.com/NewFuture/DDNS/actions/workflows/build.yml)
[![Publish Status](https://github.com/NewFuture/DDNS/actions/workflows/publish.yml/badge.svg)](https://github.com/NewFuture/DDNS/releases/latest)

---

## Features

- 兼容和跨平台:
  - [x] 可执行文件(无需 python 环境)
  - [x] 多系统兼容 ![cross platform](https://img.shields.io/badge/platform-windows_%7C%20linux_%7C%20osx-success.svg?style=social)
  - [x] python3 支持 ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ddns.svg?style=social)(2.x支持python2和python3)
  - [x] PIP 安装 ![PyPI - Wheel](https://img.shields.io/pypi/wheel/ddns.svg?style=social)
  - [x] Docker 支持(@NN708)
- 域名支持:
  - [x] 多个域名支持
  - [x] 多级域名解析
  - [x] 自动创建新记录
- IP 类型:
  - [x] 内网 IPv4 / IPv6
  - [x] 公网 IPv4 / IPv6 (支持自定义 API)
  - [x] 自定义命令(shell)
  - [x] 正则选取支持(@rufengsuixing)
- 网络代理:
  - [x] http 代理支持
  - [x] 多代理自动切换
- 服务商支持:
  - [x] [DNSPOD](https://www.dnspod.cn/)
  - [x] [阿里 DNS](http://www.alidns.com/)
  - [x] [DNS.COM](https://www.dns.com/)(@loftor-git)
  - [x] [DNSPOD 国际版](https://www.dnspod.com/)
  - [x] [CloudFlare](https://www.cloudflare.com/)(@tongyifan)
  - [x] [HE.net](https://dns.he.net/)(@NN708) (不支持自动创建记录)
  - [x] [华为云](https://huaweicloud.com/)(@cybmp3)
- 其他:
  - [x] 可设置定时任务
  - [x] TTL 配置支持
  - [x] 本地文件缓存(减少 API 请求)
  - [x] 地址变更时触发自定义回调API(与 DDNS 功能互斥)

## 使用

### ① 安装

根据需要选择一种方式: `二进制`版,`pip`版,`源码`运行,或者`Docker`

- #### pip 安装(需要 pip 或 easy_install)
  1. 安装 ddns: `pip install ddns` 或 `easy_install ddns`
  2. 运行: `ddns`
- #### 二进制版(单文件,无需 python)
  - Windows [ddns.exe](https://github.com/NewFuture/DDNS/releases/latest)
  - Linux (仅 Ubuntu 测试) [ddns](https://github.com/NewFuture/DDNS/releases/latest)
  - Mac OSX [ddns-osx](https://github.com/NewFuture/DDNS/releases/latest)
- #### 源码运行(无任何依赖, 需 python 环境)
  1. clone 或者[下载此仓库](https://github.com/NewFuture/DDNS/archive/master.zip)并解压
  2. 运行./run.py (widnows 双击`run.bat`或者运行`python run.py`)
- #### Docker(需要安装 Docker)
  - 使用环境变量:
    ```
    docker run -d \
      -e DDNS_DNS=dnspod \
      -e DDNS_ID=12345 \
      -e DDNS_TOKEN=mytokenkey \
      -e DDNS_IPV4=ddns.newfuture.cc \
      -e DDNS_IPV6=ddns.newfuture.cc \
      --network host \
      newfuture/ddns
    ```
  - 使用配置文件:
    ```
    docker run -d \
      -v /path/to/config.json:/config.json \
      --network host \
      newfuture/ddns
    ```

### ② 快速配置

1. 申请 api `token`,填写到对应的`id`和`token`字段:

   - [DNSPOD(国内版)创建 token](https://support.dnspod.cn/Kb/showarticle/tsid/227/)
   - [阿里云 accesskey](https://help.aliyun.com/document_detail/87745.htm)
   - [DNS.COM API Key/Secret](https://www.dns.com/member/apiSet)
   - [DNSPOD(国际版)](https://www.dnspod.com/docs/info.html#get-the-user-token)
   - [CloudFlare API Key](https://support.cloudflare.com/hc/en-us/articles/200167836-Where-do-I-find-my-Cloudflare-API-key-) (除了`email + API KEY`,也可使用`Token`需要列出 Zone 权限)
   - [HE.net DDNS 文档](https://dns.he.net/docs.html)(仅需将设置的密码填入`token`字段,`id`字段可留空)
   - [华为 APIKEY 申请](https://console.huaweicloud.com/iam/)(点左边访问密钥,然后点新增访问密钥)
   - 自定义回调的参数填写方式请查看下方的自定义回调配置说明

2. 修改配置文件,`ipv4`和`ipv6`字段,为待更新的域名,详细参照配置说明

## 详细配置

所有字段可通过三种方式进行配置

1. 命令行参数 `ddns --key=value` (`ddns -h` 查看详情),优先级最高
2. JSON配置文件(值为null认为是有效值,会覆盖环境变量的设置,如果没有对应的key则会尝试试用环境变量)
3. 环境变量DDNS_前缀加上key 全大写或者全小写 (`${ddns_key}` 或 `${DDNS_KEY}`)

<details open>

<summary markdown="span">config.json 配置文件
</summary>

- 首次运行会自动生成一个模板配置文件
- 可以使用 `-c`使用指定的配置文件 (默认读取当前目录的 config.json)
- 推荐使用 vscode 等支持 JsonSchema 的编辑器编辑配置文件

```bash
ddns -c path/to/config.json
# 或者源码运行
python run.py -c /path/to/config.json
```

#### 配置参数表

|  key   |        type        | required |   default   |    description    | tips                                                                                                        |
| :----: | :----------------: | :------: | :---------: | :---------------: | ----------------------------------------------------------------------------------------------------------- |
|   id   |       string       |    √     |     无      |    api 访问 ID    | Cloudflare 为邮箱(使用 Token 时留空)<br>HE.net 可留空<br>华为云为 Access Key ID (AK)                                                       |
| token  |       string       |    √     |     无      |  api 授权 token   | 部分平台叫 secret key , **反馈粘贴时删除**                                                                  |
|  dns   |       string       |    No    | `"dnspod"`  |    dns 服务商     | 阿里 DNS 为`alidns`,<br>Cloudflare 为 `cloudflare`,<br>dns.com 为 `dnscom`,<br>DNSPOD 国内为 `dnspod`,<br>DNSPOD 国际版为 `dnspod_com`,<br>HE.net 为`he`,<br>华为 DNS 为`huaweidns`,<br>自定义回调为`callback` |
|  ipv4  |       array        |    No    |    `[]`     |   ipv4 域名列表   | 为`[]`时,不会获取和更新 IPv4 地址                                                                           |
|  ipv6  |       array        |    No    |    `[]`     |   ipv6 域名列表   | 为`[]`时,不会获取和更新 IPv6 地址                                                                           |
| index4 | string\|int\|array |    No    | `"default"` |   ipv4 获取方式   | 可设置`网卡`,`内网`,`公网`,`正则`等方式                                                                     |
| index6 | string\|int\|array |    No    | `"default"` |   ipv6 获取方式   | 可设置`网卡`,`内网`,`公网`,`正则`等方式                                                                     |
|  ttl   |       number       |    No    |   `null`    | DNS 解析 TTL 时间 | 不设置采用 DNS 默认策略                                                                                     |
| proxy  |       string       |    No    |     无      | http 代理`;`分割  | 多代理逐个尝试直到成功,`DIRECT`为直连                                                                       |
| debug  |        bool        |    No    |   `false`   |   是否开启调试    | 运行异常时,打开调试输出,方便诊断错误                                                                        |
| cache  |    string\|bool    |    No    |   `true`    |   是否缓存记录    | 正常情况打开避免频繁更新,默认位置为临时目录下`ddns.cache`,<br>也可以指定一个具体文件实现自定义文件缓存位置         |

#### index4 和 index6 参数说明

- 数字(`0`,`1`,`2`,`3`等): 第 i 个网卡 ip
- 字符串`"default"`(或者无此项): 系统访问外网默认 IP
- 字符串`"public"`: 使用公网 ip(使用公网 API 查询,url 的简化模式)
- 字符串`"url:xxx"`: 打开 URL `xxx`(如:`"url:http://ip.sb"`),从返回的数据提取 IP 地址
- 字符串`"regex:xxx"` 正则表达(如`"regex:192.*"`): 提取`ifconfig`/`ipconfig`中与之匹配的首个 IP 地址,**注意 json 转义**(`\`要写成`\\`)
  - `"192.*"`表示 192 开头的所有 ip
  - 如果想匹配`10.00.xxxx`应该写成`"regex:10\\.00\\..\*"`(`"\\"`json 转义成`\`)
- 字符串`"cmd:xxxx"`: 执行命令`xxxx`的 stdout 输出结果作为目标 IP
- 字符串`"shell:xxx"`: 使用系统 shell 运行`xxx`,并把结果 stdout 作为目标 IP
- `false`: 强制禁止更新 ipv4 或 ipv6 的 DNS 解析
- 列表:依次执行列表中的index规则,并将最先获得的结果作为目标 IP
  - 例如`["public", "172.*"]`将先查询公网API,未获取到IP后再从本地寻找172开头的IP

#### 自定义回调配置说明

- `id` 字段填写回调地址,以 HTTP 或 HTTPS 开头,推荐采用 HTTPS 方式的回调 API ,当 `token` 字段非空且 URL 参数包含下表所示的常量字符串时,常量会被程序替换为实际值
- `token` 字段为 POST 参数,本字段为空或不存在则使用 GET 方式发起回调,回调参数采用 JSON 格式编码,当 JSON 的首层参数值包含下表所示的常量字符串时,常量会被程序替换为实际值

| 常量名称          | 常量内容               | 说明      |
| ---------------- | ---------------------- | -------- |
| `__DOMAIN__`     | DDNS 域名              |          |
| `__RECORDTYPE__` | DDNS 记录类型           |          |
| `__TTL__`        | DDNS TTL               |          |
| `__TIMESTAMP__`  | 请求发起时间戳          | 包含小数 |
| `__IP__`         | 获取的对应类型的IP地址   |          |

#### 配置示例

```json
{
  "$schema": "https://ddns.newfuture.cc/schema/v2.8.json",
  "id": "12345",
  "token": "mytokenkey",
  "dns": "dnspod 或 dnspod_com 或 alidns 或 dnscom 或 cloudflare 或 he 或 huaweidns 或 callback",
  "ipv4": ["ddns.newfuture.cc", "ipv4.ddns.newfuture.cc"],
  "ipv6": ["ddns.newfuture.cc", "ipv6.ddns.newfuture.cc"],
  "index4": 0,
  "index6": "public",
  "ttl": 600,
  "proxy": "127.0.0.1:1080;DIRECT",
  "debug": false
}
```

</details>

## 定时任务

<details>

<summary markdown="span">可以通过脚本设置定时任务(默认每5分钟检查一次ip,自动更新)
</summary>

#### Windows

- [推荐]以系统身份运行,右键"以管理员身份运行"`task.bat`(或者在管理员命令行中运行)
- 以当前用户身份运行定时任务,双击或者运行`task.bat` (执行时会闪黑框)

#### Linux

- 使用init.d和crontab:
`sudo ./task.sh`
- 使用systemd:
    ```bash
    安装:
    sudo ./systemd.sh install
    卸载:
    sudo ./systemd.sh uninstall
    ```
  该脚本安装的文件符合 [Filesystem Hierarchy Standard (FHS)](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard):
  可执行文件所在目录为 `/usr/share/DDNS`
  配置文件所在目录为 `/etc/DDNS`

#### Docker

Docker镜像在无额外参数的情况下,已默认启用每5分钟执行一次的定时任务
</details>

## FAQ

<details>

<summary markdown="span"> Windows Server [SSL: CERTIFICATE_VERIFY_FAILED]
</summary>

> Windows Server 默认安全策略会禁止任何未添加的信任 ssl 证书,可手动添加一下对应的证书 [#56](https://github.com/NewFuture/DDNS/issues/56#issuecomment-487371078)

使用系统自带的 IE 浏览器访问一次对应的 API 即可

- alidns 打开: <https://alidns.aliyuncs.com>
- cloudflare 打开: <https://api.cloudflare.com>
- dns.com 打开: <https://www.dns.com>
- dnspod.cn 打开: <https://dnsapi.cn>
- dnspod 国际版: <https://api.dnspod.com>
- 华为 DNS <https://dns.myhuaweicloud.com>
  </details>

<details>

<summary markdown="span"> 问题排查反馈
</summary>

1. 先确认排查是否是系统/网络环境问题
2. 在[issues](https://github.com/NewFuture/DDNS/issues)中搜索是否有类似问题
3. 前两者均无法解决或者确定是 bug,[在此新建 issue](https://github.com/NewFuture/DDNS/issues/new)
   - [ ] 开启 debug 配置
   - [ ] 附上这些内容 **运行版本和方式**,**系统环境**, **出错日志**,**去掉 id/token**的配置文件
   - [ ] 源码运行注明使用的 python 环境

</details>

            

Raw data

            {
    "_id": null,
    "home_page": "https://ddns.newfuture.cc",
    "name": "ddns",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=2.5",
    "maintainer_email": null,
    "keywords": "ddns ipv6 ipv4 dns dnspod alidns cloudflare",
    "author": "NewFuture",
    "author_email": "python@newfuture.cc",
    "download_url": "https://files.pythonhosted.org/packages/f7/7b/856583dbccad0fb14bf4684f988b44a35f9476538a8879b927df4e1bbb51/ddns-3.0.2.tar.gz",
    "platform": "any",
    "description": "# [DDNS](https://github.com/NewFuture/DDNS)\n\n> \u81ea\u52a8\u66f4\u65b0 DNS \u89e3\u6790 \u5230\u672c\u673a IP \u5730\u5740,\u652f\u6301 ipv4 \u548c ipv6 \u4ee5 \u672c\u5730(\u5185\u7f51)IP \u548c \u516c\u7f51 IP\u3002\n> \u4ee3\u7406\u6a21\u5f0f,\u652f\u6301\u81ea\u52a8\u521b\u5efa\u57df\u540d\u8bb0\u5f55\u3002\n\n[![PyPI](https://img.shields.io/pypi/v/ddns.svg?label=DDNS&style=social)](https://pypi.org/project/ddns/)\n[![Build Status](https://github.com/NewFuture/DDNS/actions/workflows/build.yml/badge.svg?event=push)](https://github.com/NewFuture/DDNS/actions/workflows/build.yml)\n[![Publish Status](https://github.com/NewFuture/DDNS/actions/workflows/publish.yml/badge.svg)](https://github.com/NewFuture/DDNS/releases/latest)\n\n---\n\n## Features\n\n- \u517c\u5bb9\u548c\u8de8\u5e73\u53f0:\n  - [x] \u53ef\u6267\u884c\u6587\u4ef6(\u65e0\u9700 python \u73af\u5883)\n  - [x] \u591a\u7cfb\u7edf\u517c\u5bb9 ![cross platform](https://img.shields.io/badge/platform-windows_%7C%20linux_%7C%20osx-success.svg?style=social)\n  - [x] python3 \u652f\u6301 ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ddns.svg?style=social)(2.x\u652f\u6301python2\u548cpython3)\n  - [x] PIP \u5b89\u88c5 ![PyPI - Wheel](https://img.shields.io/pypi/wheel/ddns.svg?style=social)\n  - [x] Docker \u652f\u6301(@NN708)\n- \u57df\u540d\u652f\u6301:\n  - [x] \u591a\u4e2a\u57df\u540d\u652f\u6301\n  - [x] \u591a\u7ea7\u57df\u540d\u89e3\u6790\n  - [x] \u81ea\u52a8\u521b\u5efa\u65b0\u8bb0\u5f55\n- IP \u7c7b\u578b:\n  - [x] \u5185\u7f51 IPv4 / IPv6\n  - [x] \u516c\u7f51 IPv4 / IPv6 (\u652f\u6301\u81ea\u5b9a\u4e49 API)\n  - [x] \u81ea\u5b9a\u4e49\u547d\u4ee4(shell)\n  - [x] \u6b63\u5219\u9009\u53d6\u652f\u6301(@rufengsuixing)\n- \u7f51\u7edc\u4ee3\u7406:\n  - [x] http \u4ee3\u7406\u652f\u6301\n  - [x] \u591a\u4ee3\u7406\u81ea\u52a8\u5207\u6362\n- \u670d\u52a1\u5546\u652f\u6301:\n  - [x] [DNSPOD](https://www.dnspod.cn/)\n  - [x] [\u963f\u91cc DNS](http://www.alidns.com/)\n  - [x] [DNS.COM](https://www.dns.com/)(@loftor-git)\n  - [x] [DNSPOD \u56fd\u9645\u7248](https://www.dnspod.com/)\n  - [x] [CloudFlare](https://www.cloudflare.com/)(@tongyifan)\n  - [x] [HE.net](https://dns.he.net/)(@NN708) (\u4e0d\u652f\u6301\u81ea\u52a8\u521b\u5efa\u8bb0\u5f55)\n  - [x] [\u534e\u4e3a\u4e91](https://huaweicloud.com/)(@cybmp3)\n- \u5176\u4ed6:\n  - [x] \u53ef\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1\n  - [x] TTL \u914d\u7f6e\u652f\u6301\n  - [x] \u672c\u5730\u6587\u4ef6\u7f13\u5b58(\u51cf\u5c11 API \u8bf7\u6c42)\n  - [x] \u5730\u5740\u53d8\u66f4\u65f6\u89e6\u53d1\u81ea\u5b9a\u4e49\u56de\u8c03API(\u4e0e DDNS \u529f\u80fd\u4e92\u65a5)\n\n## \u4f7f\u7528\n\n### \u2460 \u5b89\u88c5\n\n\u6839\u636e\u9700\u8981\u9009\u62e9\u4e00\u79cd\u65b9\u5f0f: `\u4e8c\u8fdb\u5236`\u7248,`pip`\u7248,`\u6e90\u7801`\u8fd0\u884c,\u6216\u8005`Docker`\n\n- #### pip \u5b89\u88c5(\u9700\u8981 pip \u6216 easy_install)\n  1. \u5b89\u88c5 ddns: `pip install ddns` \u6216 `easy_install ddns`\n  2. \u8fd0\u884c: `ddns`\n- #### \u4e8c\u8fdb\u5236\u7248(\u5355\u6587\u4ef6,\u65e0\u9700 python)\n  - Windows [ddns.exe](https://github.com/NewFuture/DDNS/releases/latest)\n  - Linux (\u4ec5 Ubuntu \u6d4b\u8bd5) [ddns](https://github.com/NewFuture/DDNS/releases/latest)\n  - Mac OSX [ddns-osx](https://github.com/NewFuture/DDNS/releases/latest)\n- #### \u6e90\u7801\u8fd0\u884c(\u65e0\u4efb\u4f55\u4f9d\u8d56, \u9700 python \u73af\u5883)\n  1. clone \u6216\u8005[\u4e0b\u8f7d\u6b64\u4ed3\u5e93](https://github.com/NewFuture/DDNS/archive/master.zip)\u5e76\u89e3\u538b\n  2. \u8fd0\u884c./run.py (widnows \u53cc\u51fb`run.bat`\u6216\u8005\u8fd0\u884c`python run.py`)\n- #### Docker(\u9700\u8981\u5b89\u88c5 Docker)\n  - \u4f7f\u7528\u73af\u5883\u53d8\u91cf\uff1a\n    ```\n    docker run -d \\\n      -e DDNS_DNS=dnspod \\\n      -e DDNS_ID=12345 \\\n      -e DDNS_TOKEN=mytokenkey \\\n      -e DDNS_IPV4=ddns.newfuture.cc \\\n      -e DDNS_IPV6=ddns.newfuture.cc \\\n      --network host \\\n      newfuture/ddns\n    ```\n  - \u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\uff1a\n    ```\n    docker run -d \\\n      -v /path/to/config.json:/config.json \\\n      --network host \\\n      newfuture/ddns\n    ```\n\n### \u2461 \u5feb\u901f\u914d\u7f6e\n\n1. \u7533\u8bf7 api `token`,\u586b\u5199\u5230\u5bf9\u5e94\u7684`id`\u548c`token`\u5b57\u6bb5:\n\n   - [DNSPOD(\u56fd\u5185\u7248)\u521b\u5efa token](https://support.dnspod.cn/Kb/showarticle/tsid/227/)\n   - [\u963f\u91cc\u4e91 accesskey](https://help.aliyun.com/document_detail/87745.htm)\n   - [DNS.COM API Key/Secret](https://www.dns.com/member/apiSet)\n   - [DNSPOD(\u56fd\u9645\u7248)](https://www.dnspod.com/docs/info.html#get-the-user-token)\n   - [CloudFlare API Key](https://support.cloudflare.com/hc/en-us/articles/200167836-Where-do-I-find-my-Cloudflare-API-key-) (\u9664\u4e86`email + API KEY`,\u4e5f\u53ef\u4f7f\u7528`Token`\u9700\u8981\u5217\u51fa Zone \u6743\u9650)\n   - [HE.net DDNS \u6587\u6863](https://dns.he.net/docs.html)\uff08\u4ec5\u9700\u5c06\u8bbe\u7f6e\u7684\u5bc6\u7801\u586b\u5165`token`\u5b57\u6bb5\uff0c`id`\u5b57\u6bb5\u53ef\u7559\u7a7a\uff09\n   - [\u534e\u4e3a APIKEY \u7533\u8bf7](https://console.huaweicloud.com/iam/)\uff08\u70b9\u5de6\u8fb9\u8bbf\u95ee\u5bc6\u94a5\uff0c\u7136\u540e\u70b9\u65b0\u589e\u8bbf\u95ee\u5bc6\u94a5\uff09\n   - \u81ea\u5b9a\u4e49\u56de\u8c03\u7684\u53c2\u6570\u586b\u5199\u65b9\u5f0f\u8bf7\u67e5\u770b\u4e0b\u65b9\u7684\u81ea\u5b9a\u4e49\u56de\u8c03\u914d\u7f6e\u8bf4\u660e\n\n2. \u4fee\u6539\u914d\u7f6e\u6587\u4ef6,`ipv4`\u548c`ipv6`\u5b57\u6bb5\uff0c\u4e3a\u5f85\u66f4\u65b0\u7684\u57df\u540d,\u8be6\u7ec6\u53c2\u7167\u914d\u7f6e\u8bf4\u660e\n\n## \u8be6\u7ec6\u914d\u7f6e\n\n\u6240\u6709\u5b57\u6bb5\u53ef\u901a\u8fc7\u4e09\u79cd\u65b9\u5f0f\u8fdb\u884c\u914d\u7f6e\n\n1. \u547d\u4ee4\u884c\u53c2\u6570 `ddns --key=value` (`ddns -h` \u67e5\u770b\u8be6\u60c5)\uff0c\u4f18\u5148\u7ea7\u6700\u9ad8\n2. JSON\u914d\u7f6e\u6587\u4ef6(\u503c\u4e3anull\u8ba4\u4e3a\u662f\u6709\u6548\u503c\uff0c\u4f1a\u8986\u76d6\u73af\u5883\u53d8\u91cf\u7684\u8bbe\u7f6e\uff0c\u5982\u679c\u6ca1\u6709\u5bf9\u5e94\u7684key\u5219\u4f1a\u5c1d\u8bd5\u8bd5\u7528\u73af\u5883\u53d8\u91cf)\n3. \u73af\u5883\u53d8\u91cfDDNS_\u524d\u7f00\u52a0\u4e0akey \u5168\u5927\u5199\u6216\u8005\u5168\u5c0f\u5199 (`${ddns_key}` \u6216 `${DDNS_KEY}`)\n\n<details open>\n\n<summary markdown=\"span\">config.json \u914d\u7f6e\u6587\u4ef6\n</summary>\n\n- \u9996\u6b21\u8fd0\u884c\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u6a21\u677f\u914d\u7f6e\u6587\u4ef6\n- \u53ef\u4ee5\u4f7f\u7528 `-c`\u4f7f\u7528\u6307\u5b9a\u7684\u914d\u7f6e\u6587\u4ef6 (\u9ed8\u8ba4\u8bfb\u53d6\u5f53\u524d\u76ee\u5f55\u7684 config.json)\n- \u63a8\u8350\u4f7f\u7528 vscode \u7b49\u652f\u6301 JsonSchema \u7684\u7f16\u8f91\u5668\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\n\n```bash\nddns -c path/to/config.json\n# \u6216\u8005\u6e90\u7801\u8fd0\u884c\npython run.py -c /path/to/config.json\n```\n\n#### \u914d\u7f6e\u53c2\u6570\u8868\n\n|  key   |        type        | required |   default   |    description    | tips                                                                                                        |\n| :----: | :----------------: | :------: | :---------: | :---------------: | ----------------------------------------------------------------------------------------------------------- |\n|   id   |       string       |    \u221a     |     \u65e0      |    api \u8bbf\u95ee ID    | Cloudflare \u4e3a\u90ae\u7bb1(\u4f7f\u7528 Token \u65f6\u7559\u7a7a)<br>HE.net \u53ef\u7559\u7a7a<br>\u534e\u4e3a\u4e91\u4e3a Access Key ID (AK)                                                       |\n| token  |       string       |    \u221a     |     \u65e0      |  api \u6388\u6743 token   | \u90e8\u5206\u5e73\u53f0\u53eb secret key , **\u53cd\u9988\u7c98\u8d34\u65f6\u5220\u9664**                                                                  |\n|  dns   |       string       |    No    | `\"dnspod\"`  |    dns \u670d\u52a1\u5546     | \u963f\u91cc DNS \u4e3a`alidns`,<br>Cloudflare \u4e3a `cloudflare`,<br>dns.com \u4e3a `dnscom`,<br>DNSPOD \u56fd\u5185\u4e3a `dnspod`,<br>DNSPOD \u56fd\u9645\u7248\u4e3a `dnspod_com`,<br>HE.net \u4e3a`he`,<br>\u534e\u4e3a DNS \u4e3a`huaweidns`,<br>\u81ea\u5b9a\u4e49\u56de\u8c03\u4e3a`callback` |\n|  ipv4  |       array        |    No    |    `[]`     |   ipv4 \u57df\u540d\u5217\u8868   | \u4e3a`[]`\u65f6,\u4e0d\u4f1a\u83b7\u53d6\u548c\u66f4\u65b0 IPv4 \u5730\u5740                                                                           |\n|  ipv6  |       array        |    No    |    `[]`     |   ipv6 \u57df\u540d\u5217\u8868   | \u4e3a`[]`\u65f6,\u4e0d\u4f1a\u83b7\u53d6\u548c\u66f4\u65b0 IPv6 \u5730\u5740                                                                           |\n| index4 | string\\|int\\|array |    No    | `\"default\"` |   ipv4 \u83b7\u53d6\u65b9\u5f0f   | \u53ef\u8bbe\u7f6e`\u7f51\u5361`,`\u5185\u7f51`,`\u516c\u7f51`,`\u6b63\u5219`\u7b49\u65b9\u5f0f                                                                     |\n| index6 | string\\|int\\|array |    No    | `\"default\"` |   ipv6 \u83b7\u53d6\u65b9\u5f0f   | \u53ef\u8bbe\u7f6e`\u7f51\u5361`,`\u5185\u7f51`,`\u516c\u7f51`,`\u6b63\u5219`\u7b49\u65b9\u5f0f                                                                     |\n|  ttl   |       number       |    No    |   `null`    | DNS \u89e3\u6790 TTL \u65f6\u95f4 | \u4e0d\u8bbe\u7f6e\u91c7\u7528 DNS \u9ed8\u8ba4\u7b56\u7565                                                                                     |\n| proxy  |       string       |    No    |     \u65e0      | http \u4ee3\u7406`;`\u5206\u5272  | \u591a\u4ee3\u7406\u9010\u4e2a\u5c1d\u8bd5\u76f4\u5230\u6210\u529f,`DIRECT`\u4e3a\u76f4\u8fde                                                                       |\n| debug  |        bool        |    No    |   `false`   |   \u662f\u5426\u5f00\u542f\u8c03\u8bd5    | \u8fd0\u884c\u5f02\u5e38\u65f6,\u6253\u5f00\u8c03\u8bd5\u8f93\u51fa,\u65b9\u4fbf\u8bca\u65ad\u9519\u8bef                                                                        |\n| cache  |    string\\|bool    |    No    |   `true`    |   \u662f\u5426\u7f13\u5b58\u8bb0\u5f55    | \u6b63\u5e38\u60c5\u51b5\u6253\u5f00\u907f\u514d\u9891\u7e41\u66f4\u65b0,\u9ed8\u8ba4\u4f4d\u7f6e\u4e3a\u4e34\u65f6\u76ee\u5f55\u4e0b`ddns.cache`,<br>\u4e5f\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e2a\u5177\u4f53\u6587\u4ef6\u5b9e\u73b0\u81ea\u5b9a\u4e49\u6587\u4ef6\u7f13\u5b58\u4f4d\u7f6e         |\n\n#### index4 \u548c index6 \u53c2\u6570\u8bf4\u660e\n\n- \u6570\u5b57(`0`,`1`,`2`,`3`\u7b49): \u7b2c i \u4e2a\u7f51\u5361 ip\n- \u5b57\u7b26\u4e32`\"default\"`(\u6216\u8005\u65e0\u6b64\u9879): \u7cfb\u7edf\u8bbf\u95ee\u5916\u7f51\u9ed8\u8ba4 IP\n- \u5b57\u7b26\u4e32`\"public\"`: \u4f7f\u7528\u516c\u7f51 ip(\u4f7f\u7528\u516c\u7f51 API \u67e5\u8be2,url \u7684\u7b80\u5316\u6a21\u5f0f)\n- \u5b57\u7b26\u4e32`\"url:xxx\"`: \u6253\u5f00 URL `xxx`(\u5982:`\"url:http://ip.sb\"`),\u4ece\u8fd4\u56de\u7684\u6570\u636e\u63d0\u53d6 IP \u5730\u5740\n- \u5b57\u7b26\u4e32`\"regex:xxx\"` \u6b63\u5219\u8868\u8fbe(\u5982`\"regex:192.*\"`): \u63d0\u53d6`ifconfig`/`ipconfig`\u4e2d\u4e0e\u4e4b\u5339\u914d\u7684\u9996\u4e2a IP \u5730\u5740,**\u6ce8\u610f json \u8f6c\u4e49**(`\\`\u8981\u5199\u6210`\\\\`)\n  - `\"192.*\"`\u8868\u793a 192 \u5f00\u5934\u7684\u6240\u6709 ip\n  - \u5982\u679c\u60f3\u5339\u914d`10.00.xxxx`\u5e94\u8be5\u5199\u6210`\"regex:10\\\\.00\\\\..\\*\"`(`\"\\\\\"`json \u8f6c\u4e49\u6210`\\`)\n- \u5b57\u7b26\u4e32`\"cmd:xxxx\"`: \u6267\u884c\u547d\u4ee4`xxxx`\u7684 stdout \u8f93\u51fa\u7ed3\u679c\u4f5c\u4e3a\u76ee\u6807 IP\n- \u5b57\u7b26\u4e32`\"shell:xxx\"`: \u4f7f\u7528\u7cfb\u7edf shell \u8fd0\u884c`xxx`,\u5e76\u628a\u7ed3\u679c stdout \u4f5c\u4e3a\u76ee\u6807 IP\n- `false`: \u5f3a\u5236\u7981\u6b62\u66f4\u65b0 ipv4 \u6216 ipv6 \u7684 DNS \u89e3\u6790\n- \u5217\u8868\uff1a\u4f9d\u6b21\u6267\u884c\u5217\u8868\u4e2d\u7684index\u89c4\u5219\uff0c\u5e76\u5c06\u6700\u5148\u83b7\u5f97\u7684\u7ed3\u679c\u4f5c\u4e3a\u76ee\u6807 IP\n  - \u4f8b\u5982`[\"public\", \"172.*\"]`\u5c06\u5148\u67e5\u8be2\u516c\u7f51API\uff0c\u672a\u83b7\u53d6\u5230IP\u540e\u518d\u4ece\u672c\u5730\u5bfb\u627e172\u5f00\u5934\u7684IP\n\n#### \u81ea\u5b9a\u4e49\u56de\u8c03\u914d\u7f6e\u8bf4\u660e\n\n- `id` \u5b57\u6bb5\u586b\u5199\u56de\u8c03\u5730\u5740\uff0c\u4ee5 HTTP \u6216 HTTPS \u5f00\u5934\uff0c\u63a8\u8350\u91c7\u7528 HTTPS \u65b9\u5f0f\u7684\u56de\u8c03 API \uff0c\u5f53 `token` \u5b57\u6bb5\u975e\u7a7a\u4e14 URL \u53c2\u6570\u5305\u542b\u4e0b\u8868\u6240\u793a\u7684\u5e38\u91cf\u5b57\u7b26\u4e32\u65f6\uff0c\u5e38\u91cf\u4f1a\u88ab\u7a0b\u5e8f\u66ff\u6362\u4e3a\u5b9e\u9645\u503c\n- `token` \u5b57\u6bb5\u4e3a POST \u53c2\u6570\uff0c\u672c\u5b57\u6bb5\u4e3a\u7a7a\u6216\u4e0d\u5b58\u5728\u5219\u4f7f\u7528 GET \u65b9\u5f0f\u53d1\u8d77\u56de\u8c03\uff0c\u56de\u8c03\u53c2\u6570\u91c7\u7528 JSON \u683c\u5f0f\u7f16\u7801\uff0c\u5f53 JSON \u7684\u9996\u5c42\u53c2\u6570\u503c\u5305\u542b\u4e0b\u8868\u6240\u793a\u7684\u5e38\u91cf\u5b57\u7b26\u4e32\u65f6\uff0c\u5e38\u91cf\u4f1a\u88ab\u7a0b\u5e8f\u66ff\u6362\u4e3a\u5b9e\u9645\u503c\n\n| \u5e38\u91cf\u540d\u79f0          | \u5e38\u91cf\u5185\u5bb9               | \u8bf4\u660e      |\n| ---------------- | ---------------------- | -------- |\n| `__DOMAIN__`     | DDNS \u57df\u540d              |          |\n| `__RECORDTYPE__` | DDNS \u8bb0\u5f55\u7c7b\u578b           |          |\n| `__TTL__`        | DDNS TTL               |          |\n| `__TIMESTAMP__`  | \u8bf7\u6c42\u53d1\u8d77\u65f6\u95f4\u6233          | \u5305\u542b\u5c0f\u6570 |\n| `__IP__`         | \u83b7\u53d6\u7684\u5bf9\u5e94\u7c7b\u578b\u7684IP\u5730\u5740   |          |\n\n#### \u914d\u7f6e\u793a\u4f8b\n\n```json\n{\n  \"$schema\": \"https://ddns.newfuture.cc/schema/v2.8.json\",\n  \"id\": \"12345\",\n  \"token\": \"mytokenkey\",\n  \"dns\": \"dnspod \u6216 dnspod_com \u6216 alidns \u6216 dnscom \u6216 cloudflare \u6216 he \u6216 huaweidns \u6216 callback\",\n  \"ipv4\": [\"ddns.newfuture.cc\", \"ipv4.ddns.newfuture.cc\"],\n  \"ipv6\": [\"ddns.newfuture.cc\", \"ipv6.ddns.newfuture.cc\"],\n  \"index4\": 0,\n  \"index6\": \"public\",\n  \"ttl\": 600,\n  \"proxy\": \"127.0.0.1:1080;DIRECT\",\n  \"debug\": false\n}\n```\n\n</details>\n\n## \u5b9a\u65f6\u4efb\u52a1\n\n<details>\n\n<summary markdown=\"span\">\u53ef\u4ee5\u901a\u8fc7\u811a\u672c\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1(\u9ed8\u8ba4\u6bcf5\u5206\u949f\u68c0\u67e5\u4e00\u6b21ip,\u81ea\u52a8\u66f4\u65b0)\n</summary>\n\n#### Windows\n\n- [\u63a8\u8350]\u4ee5\u7cfb\u7edf\u8eab\u4efd\u8fd0\u884c,\u53f3\u952e\"\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\"`task.bat`(\u6216\u8005\u5728\u7ba1\u7406\u5458\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c)\n- \u4ee5\u5f53\u524d\u7528\u6237\u8eab\u4efd\u8fd0\u884c\u5b9a\u65f6\u4efb\u52a1,\u53cc\u51fb\u6216\u8005\u8fd0\u884c`task.bat` (\u6267\u884c\u65f6\u4f1a\u95ea\u9ed1\u6846)\n\n#### Linux\n\n- \u4f7f\u7528init.d\u548ccrontab:\n`sudo ./task.sh`\n- \u4f7f\u7528systemd:\n    ```bash\n    \u5b89\u88c5:\n    sudo ./systemd.sh install\n    \u5378\u8f7d:\n    sudo ./systemd.sh uninstall\n    ```\n  \u8be5\u811a\u672c\u5b89\u88c5\u7684\u6587\u4ef6\u7b26\u5408 [Filesystem Hierarchy Standard (FHS)](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard)\uff1a\n  \u53ef\u6267\u884c\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u4e3a `/usr/share/DDNS`\n  \u914d\u7f6e\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u4e3a `/etc/DDNS`\n\n#### Docker\n\nDocker\u955c\u50cf\u5728\u65e0\u989d\u5916\u53c2\u6570\u7684\u60c5\u51b5\u4e0b\uff0c\u5df2\u9ed8\u8ba4\u542f\u7528\u6bcf5\u5206\u949f\u6267\u884c\u4e00\u6b21\u7684\u5b9a\u65f6\u4efb\u52a1\n</details>\n\n## FAQ\n\n<details>\n\n<summary markdown=\"span\"> Windows Server [SSL: CERTIFICATE_VERIFY_FAILED]\n</summary>\n\n> Windows Server \u9ed8\u8ba4\u5b89\u5168\u7b56\u7565\u4f1a\u7981\u6b62\u4efb\u4f55\u672a\u6dfb\u52a0\u7684\u4fe1\u4efb ssl \u8bc1\u4e66,\u53ef\u624b\u52a8\u6dfb\u52a0\u4e00\u4e0b\u5bf9\u5e94\u7684\u8bc1\u4e66 [#56](https://github.com/NewFuture/DDNS/issues/56#issuecomment-487371078)\n\n\u4f7f\u7528\u7cfb\u7edf\u81ea\u5e26\u7684 IE \u6d4f\u89c8\u5668\u8bbf\u95ee\u4e00\u6b21\u5bf9\u5e94\u7684 API \u5373\u53ef\n\n- alidns \u6253\u5f00: <https://alidns.aliyuncs.com>\n- cloudflare \u6253\u5f00: <https://api.cloudflare.com>\n- dns.com \u6253\u5f00: <https://www.dns.com>\n- dnspod.cn \u6253\u5f00: <https://dnsapi.cn>\n- dnspod \u56fd\u9645\u7248: <https://api.dnspod.com>\n- \u534e\u4e3a DNS <https://dns.myhuaweicloud.com>\n  </details>\n\n<details>\n\n<summary markdown=\"span\"> \u95ee\u9898\u6392\u67e5\u53cd\u9988\n</summary>\n\n1. \u5148\u786e\u8ba4\u6392\u67e5\u662f\u5426\u662f\u7cfb\u7edf/\u7f51\u7edc\u73af\u5883\u95ee\u9898\n2. \u5728[issues](https://github.com/NewFuture/DDNS/issues)\u4e2d\u641c\u7d22\u662f\u5426\u6709\u7c7b\u4f3c\u95ee\u9898\n3. \u524d\u4e24\u8005\u5747\u65e0\u6cd5\u89e3\u51b3\u6216\u8005\u786e\u5b9a\u662f bug,[\u5728\u6b64\u65b0\u5efa issue](https://github.com/NewFuture/DDNS/issues/new)\n   - [ ] \u5f00\u542f debug \u914d\u7f6e\n   - [ ] \u9644\u4e0a\u8fd9\u4e9b\u5185\u5bb9 **\u8fd0\u884c\u7248\u672c\u548c\u65b9\u5f0f**,**\u7cfb\u7edf\u73af\u5883**, **\u51fa\u9519\u65e5\u5fd7**,**\u53bb\u6389 id/token**\u7684\u914d\u7f6e\u6587\u4ef6\n   - [ ] \u6e90\u7801\u8fd0\u884c\u6ce8\u660e\u4f7f\u7528\u7684 python \u73af\u5883\n\n</details>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "automatically update DNS records to dynamic local IP [\u81ea\u52a8\u66f4\u65b0DNS\u8bb0\u5f55\u6307\u5411\u672c\u5730IP]",
    "version": "3.0.2",
    "project_urls": {
        "Bug Reports": "https://github.com/NewFuture/DDNS/issues",
        "Homepage": "https://ddns.newfuture.cc",
        "Source": "https://github.com/NewFuture/DDNS"
    },
    "split_keywords": [
        "ddns",
        "ipv6",
        "ipv4",
        "dns",
        "dnspod",
        "alidns",
        "cloudflare"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "296a0c6231b26dac4c2d138b72a0cb1aff084cd19a2ed1b7fca97aff830ab84c",
                "md5": "8b2290cedda9c7cc3f53bfa131a4dc39",
                "sha256": "7624cd540c4701cf97925a7cf6d47d4431022659723477fb6b8bd6dac7a6fa93"
            },
            "downloads": -1,
            "filename": "ddns-3.0.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8b2290cedda9c7cc3f53bfa131a4dc39",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": "<4,>=2.5",
            "size": 30421,
            "upload_time": "2024-06-13T12:25:22",
            "upload_time_iso_8601": "2024-06-13T12:25:22.245071Z",
            "url": "https://files.pythonhosted.org/packages/29/6a/0c6231b26dac4c2d138b72a0cb1aff084cd19a2ed1b7fca97aff830ab84c/ddns-3.0.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f77b856583dbccad0fb14bf4684f988b44a35f9476538a8879b927df4e1bbb51",
                "md5": "42b13abbc7db5abfef28eb8151ff4106",
                "sha256": "d90f2219cd608efda095d31b2eda0f3895141f61def5fa6107e94bac11ef81c4"
            },
            "downloads": -1,
            "filename": "ddns-3.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "42b13abbc7db5abfef28eb8151ff4106",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=2.5",
            "size": 24743,
            "upload_time": "2024-06-13T12:25:23",
            "upload_time_iso_8601": "2024-06-13T12:25:23.907411Z",
            "url": "https://files.pythonhosted.org/packages/f7/7b/856583dbccad0fb14bf4684f988b44a35f9476538a8879b927df4e1bbb51/ddns-3.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-13 12:25:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NewFuture",
    "github_project": "DDNS",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ddns"
}
        
Elapsed time: 0.23784s