blob: cf8af45cda9bcba5cf1521334be7d6f0dfe7e437 (
plain) (
tree)
|
|
#!rsc
# RouterOS script: update-tunnelbroker
# Copyright (c) 2013-2019 Christian Hesse <mail@eworm.de>
# Michael Gisbers <michael@gisbers.de>
:global TunnelUrl;
:global TunnelUser;
:global TunnelPass;
:global TunnelId;
:global TunnelInt;
:global CertificateAvailable;
:if ([ / ip cloud get ddns-enabled ] != true) do={
:error "IP cloud DDNS is not enabled.";
}
# get the last ip address from tunnel interface
:local TunnelLastIp [ / interface 6to4 get [ / interface 6to4 find where name=$TunnelInt ] local-address ];
# Get the current ip address from cloud
/ ip cloud force-update;
:while ([ / ip cloud get status ] != "updated") do={
:delay 1s;
}
:local TunnelIp [ / ip cloud get public-address ];
:if ($TunnelIp != $TunnelLastIp) do={
$CertificateAvailable "Starfield Secure Certificate Authority - G2" "starfield";
:log info ("Local address changed, sending UPDATE to tunnelbroker! New address: " . $TunnelIp);
/ tool fetch mode=https check-certificate=yes-without-crl \
("https://" . $TunnelUrl . "/nic/update\?hostname=" . $TunnelId) \
user=$TunnelUser password=$TunnelPass keep-result=no;
/ interface 6to4 set [ / interface 6to4 find where name=$TunnelInt ] local-address=$TunnelIp;
} else={
:log debug "All tunnelbroker configuration is up to date.";
}
|