2 Star 1 Fork 1

/ddns-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ddns-go

GitHub release

自动获得你的公网 IPv4 或 IPv6 地址,并解析到对应的域名服务。

特性

  • 支持Mac、Windows、Linux系统,支持ARM、x86架构
  • 支持的域名服务商 Alidns(阿里云) Dnspod(腾讯云) Cloudflare 华为云 Callback 百度云 porkbun GoDaddy Google Domains
  • 支持接口/网卡获取IP
  • 支持以服务的方式运行
  • 默认间隔5分钟同步一次
  • 支持多个域名同时解析,公司必备
  • 支持多级域名
  • 网页中配置,简单又方便,可设置 登录用户名和密码 / 禁止从公网访问
  • 网页中方便快速查看最近50条日志,不需要跑docker中查看
  • 支持webhook通知
  • 支持TTL
  • 支持部分dns服务商传递自定义参数,实现地域解析等功能

系统中使用

  • 下载并解压https://github.com/jeessy2/ddns-go/releases
  • 双击运行, 如没有找到配置, 程序自动打开http://127.0.0.1:9876
  • [可选] 安装服务
    • Mac/Linux: sudo ./ddns-go -s install
    • Win(以管理员打开cmd): .\ddns-go.exe -s install
    • 安装服务也支持 -l监听地址 -f同步间隔时间(秒) -c自定义配置文件路径 -noweb不启动web服务
  • [可选] 服务卸载
    • Mac/Linux: sudo ./ddns-go -s uninstall
    • Win(以管理员打开cmd): .\ddns-go.exe -s uninstall
  • [可选] 支持启动带参数 -l监听地址 -f同步间隔时间(秒) -c自定义配置文件路径 -noweb不启动web服务。如:./ddns-go -l 127.0.0.1:9876 -f 600 -c /Users/name/ddns-go.yaml

Docker中使用

  • 不挂载主机目录, 删除容器同时会删除配置

    # host模式, 同时支持IPv4/IPv6, Liunx系统推荐
    docker run -d --name ddns-go --restart=always --net=host jeessy/ddns-go
    # 桥接模式, 只支持IPv4, Mac/Windows系统推荐
    docker run -d --name ddns-go --restart=always -p 9876:9876 jeessy/ddns-go
    
  • 在浏览器中打开http://主机IP:9876,修改你的配置,成功

  • [可选] 挂载主机目录, 删除容器后配置不会丢失。可替换 /opt/ddns-go 为主机目录, 配置文件为隐藏文件

    docker run -d --name ddns-go --restart=always --net=host -v /opt/ddns-go:/root jeessy/ddns-go
    
  • [可选] 支持启动带参数 -l监听地址 -f间隔时间(秒)

    docker run -d --name ddns-go --restart=always --net=host jeessy/ddns-go -l :9877 -f 600
    

使用IPv6

  • 前提:你的电脑或终端能正常获取IPv6,并能正常访问IPv6
  • Windows/Mac:推荐 系统中使用,Windows/Mac桌面版的docker不支持--net=host
  • 群晖:
    • 套件中心下载docker并打开
    • 注册表中搜索ddns-go并下载
    • 映像 -> 选择jeessy/ddns-go -> 启动 -> 高级设置 -> 网络中勾选使用与 Docker Host 相同的网络,高级设置中勾选启动自动重新启动
    • 在浏览器中打开http://群晖IP:9876,修改你的配置,成功
  • Linux的x86或arm架构,推荐使用Docker的--net=host模式。参考 Docker中使用
  • 虚拟机中使用有可能正常获取IPv6,但不能正常访问IPv6
  • [可选] 使用IPv6后,建议勾选禁止从公网访问

Webhook

  • 支持webhook, 域名更新成功或不成功时, 会回调填写的URL

  • 支持的变量

    变量名 说明
    #{ipv4Addr} 新的IPv4地址
    #{ipv4Result} IPv4地址更新结果: 未改变 失败 成功
    #{ipv4Domains} IPv4的域名,多个以,分割
    #{ipv6Addr} 新的IPv6地址
    #{ipv6Result} IPv6地址更新结果: 未改变 失败 成功
    #{ipv6Domains} IPv6的域名,多个以,分割
  • RequestBody为空GET请求,不为空POST请求

  • Server酱: https://sctapi.ftqq.com/[SendKey].send?title=主人IPv4变了#{ipv4Addr},域名更新结果:#{ipv4Result}

  • Bark: https://api.day.app/[YOUR_KEY]/主人IPv4变了#{ipv4Addr},域名更新结果:#{ipv4Result}

  • 钉钉:

    • 钉钉电脑端 -> 群设置 -> 智能群助手 -> 添加机器人 -> 自定义
    • 只勾选 自定义关键词, 输入的关键字必须包含在RequestBody的content中, 如:你的公网IP变了
    • URL中输入钉钉给你的 Webhook地址
    • RequestBody中输入 {"msgtype": "markdown","markdown": {"title":"你的公网IP变了","text": "#### 你的公网IP变了 \n - IPV4地址:#{ipv4Addr} \n - 域名更新结果:#{ipv4Result} \n"}}
  • 飞书:

    • 飞书电脑端 -> 群设置 -> 添加机器人 -> 自定义机器人
    • 安全设置只勾选 自定义关键词, 输入的关键字必须包含在RequestBody的content中, 如:你的公网IP变了
    • URL中输入飞书给你的 Webhook地址
    • RequestBody中输入 {"msg_type": "post","content": {"post": {"zh_cn": {"title": "你的公网IP变了","content": [[{"tag": "text","text": "IPV4地址:#{ipv4Addr}"}] , [{"tag": "text","text": "域名更新结果:#{ipv4Result}"}]]}}}}
  • Telegram: ddns-telegram-bot

Callback

  • 通过自定义回调可支持更多的第三方DNS服务商

  • 配置的域名有几行, 就会回调几次

  • 支持的变量

    变量名 说明
    #{ip} 新的IPv4/IPv6地址
    #{domain} 当前域名
    #{recordType} 记录类型 AAAAA
    #{ttl} ttl
  • RequestBody为空GET请求,不为空POST请求

界面

screenshots

开发&自行编译

  • 如果喜欢从源代码编译自己的版本,可以使用本项目提供的 Makefile 构建
  • 开发环境 golang 1.19
  • 使用 make build 生成本地编译后的 ddns-go 可执行文件
  • 使用 make build_docker_image 自行编译 Docker 镜像
MIT License Copyright (c) 2020 jeessy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

ddns - go 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dabaisk/ddns-go.git
git@gitee.com:dabaisk/ddns-go.git
dabaisk
ddns-go
ddns-go
master

搜索帮助