Skip to content

ddns-updater docker来自动更新cloudflare域名A记录IP

之前用了手动的API来做了域名A记录IP的手动更新(本馆档案),我相信肯定有人做了开源的脚本了,就找到了这个。

参考

用的是这个脚本

创建专门用于DNS Edit的Token

一键梭哈

# find on your profile page
CFZONE_ID=‘a7651fc<你自己的zone_id>’ 
CFDOMAIN_RECORD_NAME='yyy.zzz'
# 下面可以填上多个多个 ‘xxx,xxx1,xxx2,www,@'等等 - 可以一次更新多个
CFDOMAIN_RECORD_HOSTPART='xxx'
CFDOMAIN_00IDEA_TOKEN='poF6Xc<上图获得的token>'

cat > ./data/config.json <<EOF
{
  "settings": [
    {
      "provider": "cloudflare",
      "zone_identifier": "$CFZONE_ID",
      "domain": "$CFDOMAIN_RECORD_NAME",
      "host": "$CFDOMAIN_RECORD_HOSTPART",
      "ttl": 600,
      "token": "$CFDOMAIN_00IDEA_TOKEN",
      "ip_version": "ipv4",
      "proxied": false,
      "no_dns_lookup": false
    }
  ]
}
EOF

cat ./data/config.json

# 默认更新是PERIOD=5m
docker stop ddns-updater; docker rm ddns-updater; \
docker run --restart=always -d -p 9200:8000/tcp \
  --name ddns-updater \
  -e PERIOD=5m \
  -v "$(pwd)"/data:/updater/data \
  qmcgaw/ddns-updater

docker logs -f ddns-updater

WEB UI

验证 – update之前和之后

Leave a Reply

Your email address will not be published.