#ip地址 #UPnP #Cloudflare #DDNS #DNS #DNS记录

app ddns-update-daemon

使用UPnP的DynDNS更新守护进程

1个稳定版本

1.0.0 2024年5月5日

#1598 in 网络编程

MIT许可证

37KB
787

DynDNS更新守护进程

一个使用通用插头和插座 (UPnP) 定期检查互联网网关的外部IP地址的动态DNS (ddns) 守护进程,如果它已更改,则向ddns服务推送更新或运行程序。

如果将 router_ip 设置为回环地址 127.0.0.1,则ddns-update-daemon将监视本地IP而不是远程IP。在这种情况下,不会发送UPnP查询。

在Linux、Windows和Mac上运行。
(在Linux上使用rustls,在其他地方使用操作系统的默认设置)。

特性

  • 使用UPnP监视外部IP地址。
    • 注意:此不需要启用UPnP端口转发。
  • 监视本地IP地址。
  • 更新器
    • Cloudflare 通过使用cloudflare API更新DNS记录。
    • 请求自定义URL(例如,用于dynu、no-ip等)。
    • 运行程序。
  • IPv6
    • 主要只在FRITZ!Box 路由器上受支持。

安装

从当前发布 安装预构建的可执行文件。

或者,从源代码构建并使用以下方式安装

cargo install ddns-update-daemon

(需要安装Rust)。

配置

ddns-update-daemon需要一个配置toml文件作为第一个命令行参数。(运行 ddns-update-daemon --help 获取有关CLI的帮助信息)。

配置格式如下

# The check interval in minutes; may be fractional (i.e. `0.5`). Required.
interval = 30
# The IP address of the internet gateway device the be queried. Optional.
# If not specified, the first discovered internet gateway device will be used.
# If set to loopback (127.0.0.1), the local IP address will be watched
# by querying the OS of the current local IP address.
router_ip = "192.168.1.1"

# Cloudflare DNS records to update. Optional.
[cloudflare]
# The cloudflare API access token.
api_token = "<token>"
# The cloudflare zone ID of the site to be updated.
zone_id = "<zone ID>"

# One or more records to be updated. Optional.
[[cloudflare.records]]
# The name of the DNS record. Required.
name = "@"
# The type of the DNS record. Required.
# Supportes "A" or "AAAA" records.
type = "A" # or "AAAA"

# Update a DynDNS service with a request to a URL. Optional.
[[urls]]
# The method used for the update request, supports "get", "post", "put", "patch", ...
# Optional, defaults to "get".
method = "get"

# The url to send the update request to, placeholders `{ipv4}` and `{ipv6}`
# will get replaced by the IPv4 and IPv6 address that was detected.
# Required.
url = "https://api.yourservice.com/nic/update?myip={ipv4}&myipv6={ipv6}"

# Additional headers to send, placeholders `{ipv4}` and `{ipv6}` will be replaced
# with the detected IPs in the header values.
# Optional.
headers = {"name" = "value", ...}

# The body of the request, if the request supports a body.
# Placeholders `{ipv4}` and `{ipv6}` will again be replaced by the detected IPs.
# Optional.
body = ""

# Run one or more programs when new IP(s) are detected. Optional.
[[runs]]
# The program to run and command line arguments,
# `{ipv4}` and `{ipv6}` will be replaced with the detected IPs in the arguments.
# Required.
cmd = ["myprog", "{ipv4}"]

许可证:MIT

依赖关系

~11–31MB
~471K SLoC