分享一下高手寫的Cloudflare DNS API工具
https://github.com/bAndie91/cloudflare-cli
使用此工具可以透過Linux方式進行DNS記錄切換,搭配健康檢查機制,真的是非常好用
1.取得Cloudflare DNS API key
2.下載Cloudflare DNS API工具
3.指令操作切換DNS紀錄
1.取得Cloudflare DNS API key
登入Cloudflare >> my profile >> View API key
2.下載Cloudflare DNS API工具
#git clone https://github.com/bAndie91/cloudflare-cli.git
安裝curl、php php-cli
#yum -y install curl php php-cli
3.指令操作切換DNS紀錄
export cloudflare API
#export CF_Key="sdfsd70504dlkjsdf630wje"
#export CF_Email="[email protected]"
查看目前DNS 有哪些Zone
#cloudflare show zone
查看Zone 所設定的紀錄
#cloudflare show record kingxuntw.com
新增A紀錄 cloudflare add record <zone> <type> <name> <content>
<zone> domain zone to register the record in, see ‘show zones’ command
<type> one of: A, AAAA, CNAME, MX, NS, SRV, TXT, SPF, LOC
<name> subdomain name, or “@” to refer to the domain’s root
<content> IP address for A, AAAA
FQDN for CNAME, MX, NS, SRV
any text for TXT, spf definition text for SPF
#cloudflare add record kingxuntw.com A www 10.10.10.10
新增MX紀錄 cloudflare add record [ttl] [prio] [service] [protocol] [weight] [port]
#cloudflare add record syhdjd.com MX @ mail.syhdjd.com 120 10
新增CNAME紀錄 cloudflare add record [ttl] [prio] [service] [protocol] [weight] [port]
#cloudflare add record syhdjd.com CNAME www2.syhdjd.com www3.kingxuntw.com
刪除A紀錄 cloudflare delete record [<record-name> [<type> | first] | [<zone-name>|<zone-id>] <record-id>]
#cloudflare delete record www6.syhdjd.com A
刪除CNAME紀錄
#cloudflare delete record www2.syhdjd.com CNAME