记录下对服务器做了哪些配置。
ddns
获取的公网IP会变动,而路由器没有dnspod的ddns,所以直接在服务器上跑ddns也是可以的。
ddns本质就是定期获取出口IP,并自动设置域名和IP的映射。我这里直接用docker跑ddns-go服务,ddns-go设置简单,支持的服务多,可以设置webhook。
1 2 3 4 5 6 7 8 9
| version: "3" services: ddns-go: container_name: ddns-go restart: always network_mode: host volumes: - /home/by/ddns-go:/root image: jeessy/ddns-go:v6.1.1
|
然后去dnspod的个人中心里获取token和token id,在本地9876端口下的web界面里设置好基础配置就行。这里贴一个本地文件配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| dnsconf: - ipv4: enable: true gettype: url url: https://api.ipify.org, https://ddns.oray.com/checkip, https://ip.3322.net, https://4.ipw.cn netinterface: enp3s0 cmd: "" domains: - example.example.com ipv6: enable: false gettype: netInterface url: https://api64.ipify.org, https://speed.neu6.edu.cn/getIP.php, https://v6.ident.me, https://6.ipw.cn netinterface: "" cmd: "" ipv6reg: "" domains: - "" dns: name: dnspod id: "88888" secret: token ttl: "" user: username: "" password: "" webhook: webhookurl: "" webhookrequestbody: "" webhookheaders: "" notallowwanaccess: true lang: en
|
这里踩了个坑,因为dnspod已经是腾讯的了,所以我一开始选的腾讯云。另外获取token也要注意获取的是腾讯的还是dnspod。
然后使用chanify配置一下ip变更的提醒
1
| https://api.chanify.net/v1/sender/<token>/IPv4变动:#{ipv4Addr},域名更新结果:#{ipv4Result}
|
参考文章
https://cloud.tencent.com/developer/article/1921363