Dynamic DNS Update Script for Hurricane Electric DNS - MikroTik Script RouterOS

This script will update the IP address on Hurricane Electric DNS service (http://dns.he.net/)

It updates the A/AAAA record so both IPv4 and IPv6 can be supplied.

It uses the fetch command with the url= parameter. Check that your version of RouterOS -> /tool fetch supports this option.

The following URL to supply update information is used:

For auto IP detection:

For manually setting the IP address:

For more information, see this link: http://dns.he.net/

The script:

# Update Hurricane Electric DDNS IPv4 address
:local ddnshost ""
:local key "key"
:local updatehost "dyn.dns.he.net"
:local WANinterface ""
:local outputfile ("HE_DDNS" . ".txt")
# Internal processing below...
# ----------------------------------
:local ipv4addr
# Get WAN interface IP address
:set ipv4addr [/ip address get [/ip address find interface=$WANinterface] address]
:set ipv4addr [:pick [:tostr $ipv4addr] 0 [:find [:tostr $ipv4addr] "/"]]
:if ([:len $ipv4addr] = 0) do={
   :log error ("Could not get IP for interface " . $WANinterface)
   :error ("Could not get IP for interface " . $WANinterface)
:log info ("Updating DDNS IPv4 address" . " Client IPv4 address to new IP " . $ipv4addr . "...")
/tool fetch url="http://$ddnshost:$key@$updatehost/nic/update?hostname=$ddnshost&myip=$ipv4addr"  \
:log info ([/file get ($outputfile) contents])
/file remove ($outputfile)
Note: The above script works with ROS 3.x. For the 5.x a minor modification for the fetch command is needed:

/tool fetch mode=http url="http://$ddnshost:$key@$updatehost/nic/update?hostname=$ddnshost&myip=$ipv4addr" \
Credit: https://wiki.mikrotik.com