also here
备忘
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ################# CloudFlare variables ################# :local CFDebug "true" :global WANInterface "pppoe4plex" :local CFdomain "*****.lingbo.me" :local CFzone "lingbo.me" :local CFrecordType "A" :local CFemail "****************@gmail.com" :local CFtkn "bc24e143b3840****************9e13a5" :local CFzoneid "a926a****************accb8" :local CFid "661c43a****************95994087" ######################################################################### ######################## DO NOT EDIT BELOW ############################ ######################################################################### ################# Internal variables ################# :local resolvedIP "" :global WANip "" ################# Resolve and set IP-variables ################# :local currentIP [/ip address get [/ip address find interface=$WANInterface ] address]; :set WANip [:pick $currentIP 0 [:find $currentIP "/"]]; :set resolvedIP [:resolve $CFdomain]; ################# Build CF API Url (v4) ################# :local CFurl "https://api.cloudflare.com/client/v4/zones/" :set CFurl ($CFurl . "$CFzoneid/dns_records/$CFid"); ######## Write debug info to log ################# :if ($CFDebug = "true") do={ :log info ("CF: hostname = $CFdomain") :log info ("CF: resolvedIP = $resolvedIP") :log info ("CF: currentIP = $currentIP") :log info ("CF: WANip = $WANip") :log info ("CF: CFurl = $CFurl&content=$WANip") }; ######## Compare and update CF if necessary ##### :if ($resolvedIP != $WANip) do={ :log info ("CF: Updating CF, setting $CFDomain = $WANip") /tool fetch http-method=put mode=https url="$CFurl" http-header-field="X-Auth-Email:$CFemail,X-Auth-Key:$CFtkn,content-type:application/json" output=none http-data="{"type":"$CFrecordType","name":"$CFdomain","content":"$WANip"}" /ip dns cache flush } else={ :log info "CF: No Update Needed!" } |
没有评论:
发表评论