MENU

使用GoDNS配合CloudFlare API为动态IP NAT VPS绑定域名(DDNS)

August 17, 2019 • Read: 321 • linux

GODNS官方文档请查看https://github.com/TimothyYe/godns

1、debian9先更新:

apt-get update
apt-get -y install ca-certificates

2、从GitHub下载GODNS:

wget -N --no-check-certificate https://github.com/TimothyYe/godns/releases/download/V1.9/godns-linux64-V1.9.tar.gz
tar zxvf godns-linux64-V1.9.tar.gz

3、从CloudFlare获取Global API Key:

cf.png

  1. STEP1:点击My Profile进入profile页面
  2. STEP2:点击View获取Global API Key

4、将以下代码保存为config.json,并和解压后的godns文件放在同一个目录:

  • email填写你的cloudflare账户邮箱
  • password填写上一步获取的Global API Key
  • domain_name填写你的根域名
  • sub_domain填写你的二级域名(二级域名需要先在cloudflare中添加一条指向任意IP的A记录

    {

     "provider": "Cloudflare",
     "email": "you@example.com",
     "password": "Global API Key",
     "domains": [{
         "domain_name": "example.com",
         "sub_domains": ["www","test"]
       },{
         "domain_name": "example2.com",
         "sub_domains": ["www","test"]
       }
     ],
     "ip_url": "https://myip.biturl.top",
     "interval": 300,
     "socks5_proxy": ""

    }

5、创建systemd服务:

将以下内容保存为godns.service:

[Unit]
Description=GoDNS Service
After=network.target

[Service]
ExecStart=/godns文件放置目录/godns -c=/godns文件放置目录/config.json
Restart=always
KillMode=process
RestartSec=2s

[Install]
WantedBy=multi-user.target

将godns.service文件放到/lib/systemd/system目录中

6、执行命令:

systemctl enable godns
systemctl start godns

至此,GODNS已成功配置并运行,将会每300秒自动设置DNS记录

Last Modified: August 18, 2019
Leave a Comment

2 Comments
  1. jin jin

    路过路过,666

  2. jacob jacob

    大闯你 邮箱多少 发封邮件给我 邮箱你知道的---Jacob