2019
11-20

RouterOS Cloudflare DDNS Script 脚本Cloudflare DDNS插件Script脚本

RouterOS Cloudflare DDNS Script 脚本Cloudflare DDNS插件Script脚本

RouterOS Cloudflare DDNS Script 脚本

################# 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!"

}

官方QQ群号码:922069959
点击链接加入群聊【路由器交流】:https://jq.qq.com/?_wv=1027&k=5AKdmZP

您可能感兴趣的文章

支付宝打赏支付宝打赏 微信打赏微信打赏

本站》评论功能已永久关闭

官方QQ群号码:922069959
点击链接加入群聊【路由器交流】:
https://jq.qq.com/?_wv=1027&k=5AKdmZP
官方QQ群号码:922069959