#!/bin/sh# # Import ardnspod functions. /root/dnspod-shell/ardnspod # Combine your token ID and token together as followsarToken="22312325,c6b13213884dbd4423123231236" # Place each domain you want to check as follows# you can have multiple arDdnsCheck blocks # IPv4:arDdnsCheck "baidu.com" "sh"
root@coal-299r2bvb:~/dnspod-shell# ./ddnspod.sh Fetching Host Ip> Host Ip: 139.226.50.77> Record Type: AFetching Ids of sh.baidu.com> Domain Ids: 76015004 1050820226Checking Record for sh.baidu.com> Last Ip: 1.1.1.1Updating Record for sh.cve.pub> arDdnsUpdate - success
vim /usr/lib/systemd/system/ddns.service [Unit]Description=ddnsAfter=network.target [Service]Type=simpleUser=rootWorkingDirectory=/root/dnspod-shell/ExecStart=/root/dnspod-shell/ddnspod.sh [Install]WantedBy=multi-user.target
然后把 ddns 作为系统服务。
systemctl start ddns
3.创建 Timer 单元
由于碳云的更新IP后很影响用户,因此可以设置每分钟检测一次。
可以写成
vim /usr/lib/systemd/system/ddns.timer [Unit]Description=Run ddns every 1m [Timer]OnBootSec=5minOnUnitActiveSec=1minUnit=ddns.service [Install]WantedBy=timers.target