#!rsc # RouterOS script: update-tunnelbroker # Copyright (c) 2013-2019 Christian Hesse # Michael Gisbers :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."; }