# update_20230828
# update Hurricane Electric ddns
:local slog "::The Start -- Update Hurricane Electric DDNS..."
:local elog "::The End -- Update Hurricane Electric DDNS..."
:log info (" ------" . "\n" . $slog)
:local HEusrhost "www.your.domain";
:local HEddnskey "www.tunnelbroker.net_adanced_he-Dynamic-DNS-Settings_API-Key";
:local HEhost "dyn.dns.he.net";
:local HEpath "/nic/update";
:local WANether "pppoe-out1";
:local HEotptfile ("external/" . "HE_DDNS" . ".txt");
:local lwanaddr4;\
:set lwanaddr4 [/ip address get [/ip address find \
interface=$WANether] address];
:set lwanaddr4 [:pick [:tostr $lwanaddr4] 0 \
[:find [:tostr $lwanaddr4] "/"]];
:if ([:len $lwanaddr4] = 0) do={
:log error (" :Could not get IP for interface " . \
$WANether . "\n" . $elog . "\n" . " - - - - - -");
:error message=(" :Could not get IP for interface " . \
$WANether . "\n::The End -- Update Hurricane Electric DDNS...");
};
:local lHE4now;
:do {
/ip dns cache flush;\
:set lHE4now [:resolve "$HEusrhost"];
} on-error={\
:log warning (" :failed to resolve " . $HEusrhost . \
". Will updating HE-DDNS Client IPv4 address" . \
"to new IP: " . $lwanaddr4 . "directly...");
/tool fetch mode=http url=(\
"https://" . $HEhost . \
$HEpath . "?hostname=" . \
$HEusrhost . "&password=" . \
$HEddnskey . "&myip=" . \
$lwanaddr4) dst-path=($HEotptfile);
:log info (" :" . [/file get ($HEotptfile) contents] . \
"\n" . $elog . "\n" . " - - - - - -");
:error message=" :Failed to resolve, Updated directly.";
};
:log info (" :RecordDNS is " . $lHE4now . "; MyWanIP is " . \
$lwanaddr4 . ".");
:if ($lHE4now = $lwanaddr4) do={\
:log info (" :HEDNS nochg" . "\n" . $elog . "\n" . \
" - - - - - -");
} else={\
:log info (":Updating HE DDNS Client IPv4 addr" . \
"to new IP: " . $lwanaddr4 . "...");\
/tool fetch mode=http url=(\
"https://" . \
$HEhost . $HEpath . \
"?hostname=" . $HEusrhost . \
"&password=" . $HEddnskey . \
"&myip=" . $lwanaddr4\
) \
dst-path=($HEotptfile);
:log info (" :" . [/file get ($HEotptfile) contents] . \
"\n" . $elog . "\n" . " - - - - - -");
};
/
Mikrotik RouterOS脚本_更新Hurricane Electric的tunnelbroker DDNS
最新推荐文章于 2024-08-16 07:31:15 发布