使用 shell script 更新 cloudflare 的 DNS 記錄
記錄一下使用 shell script 更新 cloudflare 的 DNS 記錄(DDNS) 工作環境: Linux curl jq 使用 curl 和 cloudflare API 溝通,就可以達成更新 DNS 記錄的目的,基本上就是提供 zone ID 和 API Token 給 cloudflare ,指定要更新的域名(FQDN),當然,要抓到目前使用的「對外」的 IP 位址一併提供 範例:updateCfDDNS flkjfldajldfj ddns.your.domain lfkdalfjldjf;lajd;lf #!/bin/sh # update DDNS records with curl using cloudflare API # input: zoneID, FQDN, APIToken, get internet IP addr. # output: none but DNS record update dynamicly # pre-requirements: config cloudflare API token # post-requirement: config crontab to update DDNS regularly # usage: updateCfDDNS zoneID FQDN APIToken if [ -z $1 ] then echo "please provide zoneId, fqdn, apiToken, thank you..." else MYIP = ` curl https://ipinfo.io/ip` RECID = ` curl -X GET "https://api.cloudflare.com/client/v4/zones/ ${1} /dns_records?name= ${2...