api更新cloudfflare dns (DDNS)
emer 发布于 2020-10-13 10:35 1594 次阅读
#!/bin/bash zone_name="55555566.xyz" 根域名 record_name='h.55555566.xyz' 要更新的域名 record_type='A' 解析类型 auth_email='liniaa@163.com' 邮箱 auth_key='token' token ip='127.0.0.1' 要变更为的ip zone_identifier=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=$zone_name" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key:$auth_key" -H "Content-Type: application/json" | grep -Po '(?<="id":")[^"]*' | head -1 ); echo "$zone_identifier"; record_identifier=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records?name=$record_name&type=$record_type" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json" | grep -Po '(?<="id":")[^"]*') echo "$record_identifier"; update=$(curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records/$record_identifier" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json" --data "{\"id\":\"$zone_identifier\",\"type\":\"$record_type\",\"name\":\"$record_name\",\"content\":\"$ip\"}") echo "$update"