Dynamic DNS Update Script for Hurricane Electric DNS
From MikroTik Wiki
This script will update the IP address on (Hurricane Electric DNS service).
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:
http://dyn.example.com:password@dyn.dns.he.net/nic/update?hostname=dyn.example.com
- For manually setting the IP address:
http://dyn.example.com:password@dyn.dns.he.net/nic/update?hostname=dyn.example.com&myip=192.168.0.1
For more information, see this link: [1]
The script:
# Update Hurricane Electric DDNS IPv4 address :local ddnshost "<dyndnshost>" :local key "key" :local updatehost "dyn.dns.he.net" :local WANinterface "<if>" :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" dst-path=$outputfile :log info ([/file get ($outputfile) contents]) /file remove ($outputfile)