2019-05-02 12:58:52 +08:00
2019-04-20 15:19:44 +08:00
2019-05-02 12:58:52 +08:00
2018-07-22 08:40:23 +00:00
2019-04-20 22:37:50 +08:00
2019-05-02 12:58:52 +08:00
2019-04-20 23:55:55 +08:00
2018-07-22 16:42:58 +08:00
2019-05-01 22:55:09 +08:00
2016-11-07 21:44:26 +08:00
2018-08-06 22:43:50 +08:00
2019-05-01 22:47:26 +08:00
2019-05-02 03:36:25 +08:00
2018-07-29 13:46:24 +08:00
#27
2018-12-11 22:03:44 +08:00

DDNS

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

Build Status Build Status Build Status latest deploy PyPI

Ubuntu Windows Python3.7 Windows Python2.7 Mac Python3.7 Mac Python2.7
Travis Build Build Status Build Status Build Status Build Status

Features

  • 兼容和跨平台:
    • 多系统(Widnows, Linux, MacOS) cross platform
    • python2和python3支持 PyPI - Python Version
    • 无Python可执行文件
    • PIP安装 PyPI - Wheel
  • 域名支持:
    • 多个域名支持
    • 多级域名解析
    • 自动创建新记录
  • IP类型:
    • 内网IP
    • 公网IP
    • ipv6支持
    • 正则选取支持(@rufengsuixing)
  • 网络代理:
    • http代理支持
    • 多代理自动切换
  • 服务商支持:
  • 其他:
    • 可设置定时任务
    • 本地文件缓存(减少服务器请求和查询)

TODO:

  • 腾讯云
  • 同线路多记录支持
  • socks代理
  • TTL自定义(更多配置)

使用

1.安装

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

  • pip 安装(需要pipeasy_install) beta
    1. 安装ddns: pip install ddnseasy_install ddns
    2. 运行: ddns
  • 二进制版(单文件,无需任何python环境)
  • 源码运行(无任何依赖, 需要python环境)
    1. clone 或者下载此仓库并解压
    2. 运行./run.py (widnows 双击run.bat或者运行python run.py)
  • 历史版本

2.快速配置

  1. 复制 example.config.jsonconfig.json

  2. 申请 api token:

  3. 修改配置,ipv4ipv6字段,无则设为[](此时不会解析和更新对应IP),详细参照配置说明

详细配置

config.json
  • 首次运行会自动生成一个模板配置文件
  • 可以使用 -c使用指定的配置文件 (默认读取当前目录的 config.json)
  • 推荐使用vscode等支持JsonSchema的编辑器编辑配置文件
#python
python run.py -c /path/to/config.json 
#二进制可执行文件
ddns -c path/to/config.json

配置说明

key type required default comment
id string Yes api授权id(cloudflare为登录邮箱)
token string Yes api授权token
dns string No dnspod dns服务商,阿里为alidns,DNS.COM为dnscom,DNSPOD国际版为(dnspod_com)cloudflare
ipv4 array No [] ipv4 域名列表
ipv6 array No [] ipv6 域名列表
index4 string/int No 'default' ipv4获取方式
index6 string/int No 'default' ipv6获取方式
proxy string No 多个代理;分割,DIRECT表示直连,从第一个代理尝试
debug boolean No false 是否开启调试(输出调试信息)

index4和index6参数说明

  • 数字(0,1,2,3等)第i个网卡ip
  • 正则表达(如"192.*") 提取ifconfig/ipconfig中与之匹配的首个IP地址,注意json转义(\要写成\\)
    • "192.*"表示192开头的所有ip
    • 如果想匹配10.00.xxxx应该写成"10\\.00\\..*"("\\"json转义成\)
  • 字符串"default"(或者无此项) 系统访问外网默认IP
  • 字符串"public"使用公网ip(使用公网API查询)
  • false 强制禁止更新ipv4或ipv6的DNS解析

配置示例

{
    "$schema": "https://ddns.newfuture.cc/schema.json",
	"id": "12345",
	"token": "mythokenkey",
	"dns": "dnspod 或 dnspod_com 或 alidns 或 dnscom 或 cloudflare",
	"ipv4": [
		"ddns.newfuture.xyz",
		"ipv4.ddns.newfuture.xyz"
	],
	"ipv6": [
		"ddns.newfuture.xyz",
		"ipv6.ddns.newfuture.xyz"
	],
	"index4": 0,
	"index6": "public",
	"proxy": "127.0.0.1:1111",
	"debug": false
}

定时任务

可以通过脚本设置定时任务(默认每5分钟检查一次ip,自动更新)

windows

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

linux

运行 sudo ./task.sh

FAQ

Windows Server [SSL: CERTIFICATE_VERIFY_FAILED]

Windows Server 默认安全策略会禁止任何未添加的信任ssl证书,可手动添加一下对应的证书 #56

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

S
Description
No description provided
Readme
454 KiB
Languages
Python 93.6%
Shell 4.6%
Batchfile 1.4%
Dockerfile 0.4%