09-06-2015, 10:21
This script will update a Hurricane Electric IPv6 Tunnel Client IPv4 address.
This script uses the fetch command with the url= parameter. Check that your version of RouterOS -> /tool fetch supports this option.
This script also works great when integrated with a dynamic DNS updater script.
For complete instructions on how to update your Hurricane Electric IPv6 Tunnel Client IPv4 address, see this link:
This script uses http (not HTTPS), as RouterOS fetch command does not support the HTTPS protocol.
The script:
This script uses the fetch command with the url= parameter. Check that your version of RouterOS -> /tool fetch supports this option.
This script also works great when integrated with a dynamic DNS updater script.
For complete instructions on how to update your Hurricane Electric IPv6 Tunnel Client IPv4 address, see this link:
This script uses http (not HTTPS), as RouterOS fetch command does not support the HTTPS protocol.
The script:
Codice:
# Update Hurricane Electric IPv6 Tunnel Client IPv4 address
:local HEtunnelinterface "<this router's tunnel interface name>"
:local HEtunnelid "<tunnel id>"
:local HEuserid "<user id>"
:local HEmd5pass "<md5 hash of password>"
:local HEupdatehost "ipv4.tunnelbroker.net"
:local HEupdatepath "/ipv4_end.php"
:local WANinterface "WAN"
:local outputfile ("HE-" . $HEtunnelid . ".txt")
# Internal processing below...
# ----------------------------------
:local HEipv4addr
# Get WAN interface IP address
:set HEipv4addr [/ip address get [/ip address find interface=$WANinterface] address]
:set HEipv4addr [:pick [:tostr $HEipv4addr] 0 [:find [:tostr $HEipv4addr] "/"]]
:if ([:len $HEipv4addr] = 0) do={
:log error ("Could not get IP for interface " . $WANinterface)
:error ("Could not get IP for interface " . $WANinterface)
}
# Update the HEtunnelinterface with WAN IP
/interface 6to4 {
:if ([get ($HEtunnelinterface) local-address] != $HEipv4addr) do={
:log info ("Updating " . $HEtunnelinterface . " local-address with new IP " . $HEipv4addr . "...")
set ($HEtunnelinterface) local-address=$HEipv4addr
}
}
:log info ("Updating IPv6 Tunnel " . $HEtunnelid . " Client IPv4 address to new IP " . $HEipv4addr . "...")
/tool fetch mode=http \
host=($HEupdatehost) \
url=("http://" . $HEupdatehost . $HEupdatepath . \
"?ipv4b=" . $HEipv4addr . \
"&pass=" . $HEmd5pass . \
"&user_id=" . $HEuserid . \
"&tunnel_id=" . $HEtunnelid) \
dst-path=($outputfile)
:log info ([/file get ($outputfile) contents])
/file remove ($outputfile)