#api key:FGhh70xa4LFy4gZzHibAOL1Yoy1-SFQ1glZrmxxx
#zone id:7325cc65280f73b3573bd3ec03bb3xxx
检测key是否正常
curl -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \
-H "Authorization: Bearer FGhh70xa4LFy4gZzHibAOL1Yoy1-SFQ1glZrmxxx" \
-H "Content-Type:application/json"
获取dns记录详细列表(此处可以获取到对应域名的identifier值)
curl --request GET \
--url https://api.cloudflare.com/client/v4/zones/7325cc65280f73b3573bd3ec03bb3xxx/dns_records \
-H "Authorization: Bearer FGhh70xa4LFy4gZzHibAOL1Yoy1-SFQ1glZrmxxx" \
-H "Content-Type:application/json"
#返回结果:
{
"result": [
{
"id": "bcf1f4d63adbd02919a07ae10c1cbxxx",
"zone_id": "7325cc65280f73b3573bd3ec03bb3xxx",
"zone_name": "cqgyd.com",
"name": "chat.cqgyd.com",
"type": "A",
"content": "167.160.189.46",
"proxiable": true,
"proxied": false,
"ttl": 1,
"locked": false,
"meta": {
"auto_added": false,
"managed_by_apps": false,
"managed_by_argo_tunnel": false,
"source": "primary"
},
"comment": null,
"tags": [],
"created_on": "2023-06-01T13:18:20.56627Z",
"modified_on": "2023-07-06T02:06:23.918585Z"
},
{
"id": "4d27a8e2ed76bcf42481cb1b52292492",
"zone_id": "7325cc65280f73b3573bd3ec03bb3xxx",
"zone_name": "cqgyd.com",
"name": "cqgyd.com",
"type": "A",
"content": "147.103.120.250",
"proxiable": true,
"proxied": false,
... ...
或者获取指定域名的信息(nas.cqgyd.com)
curl --location 'https://api.cloudflare.com/client/v4/zones/7325cc65280f73b3573bd3ec03bb3xxx/dns_records?name=nas.cqgyd.com' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer FGhh70xa4LFy4gZzHibAOL1Yoy1-SFQ1glZrmxxx'
#返回
{
"result": [
{
"id": "4123f6a77aa11833d7ae4f3110cf0xxx",
"zone_id": "7325cc65280f73b3573bd3ec03bb3xxx",
"zone_name": "cqgyd.com",
"name": "nas.cqgyd.com",
"type": "A",
"content": "27.10.192.184",
"proxiable": true,
"proxied": false,
"ttl": 1,
"locked": false,
"meta": {
"auto_added": false,
"managed_by_apps": false,
"managed_by_argo_tunnel": false,
"source": "primary"
},
"comment": null,
"tags": [],
"created_on": "2023-09-04T09:05:17.593395Z",
"modified_on": "2023-09-04T09:05:17.593395Z"
}
],
"success": true,
"errors": [],
"messages": [],
"result_info": {
"page": 1,
"per_page": 100,
"count": 1,
"total_count": 1,
"total_pages": 1
}
}
更新域名chat.cqgyd.com的ip
通过如上方法能获取到对应域名的identifier值。
identifier :bcf1f4d63adbd02919a07ae10c1cbxxx
修改解析的ip到对应域名上
curl --request PUT \
--url https://api.cloudflare.com/client/v4/zones/7325cc65280f73b3573bd3ec03bb3xxx/dns_records/bcf1f4d63adbd02919a07ae10c1cbxxx \
-H "Authorization: Bearer FGhh70xa4LFy4gZzHibAOL1Yoy1-SFQ1glZrmxxx" \
-H "Content-Type:application/json" \
--data '{
"content": "198.51.100.4",
"name": "chat.cqgyd.com",
"proxied": false,
"type": "A",
"comment": "Domain verification record",
"ttl": 3600
}'
Comments | NOTHING