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

2019-11-20
0评论
/
阅读
管理员

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

}

本站附件分享,如附件失效,可以去找找看
诚通网盘附件百度网盘附件
PS:由于百度网盘附件太大,所以百度网盘附件为拆分压缩,全部下载后打开zip后缀文件即可。也可以只下载zip后缀文件查看(只可以查看不能解压)是否有需要的文件,再下载全部文件解压需要的文件


干饭福利分享: 微信扫码领取“饿了么”抵用券↓↓↓↓↓↓↓↓↓↓

于2019-11-20发布