RouterOS Italia

Versione completa: [Mikrotik] Dynamic DNS Update Script for Hurricane Electric DNS
Al momento stai visualizzando i contenuti in una versione ridotta. Visualizza la versione completa e formattata.
This script will update the IP address on Hurricane Electric DNS .
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:
Codice:
http://dyn.example.com:password@dyn.dns.he.net/nic/update?hostname=dyn.example.com
  • For manually setting the IP address:
Codice:
http://dyn.example.com:password@dyn.dns.he.net/nic/update?hostname=dyn.example.com&myip=192


For more information, see this link:[url=http://dns.he.net][/url]

The script:
Codice:
# Update Hurricane Electric DDNS IPv4 address



Codice:
:local ddnshost "<dyndnshost>"

Codice:
:local key "key"

Codice:
:local updatehost "dyn.dns.he.net"

Codice:
:local WANinterface "<if>"

Codice:
:local outputfile ("HE_DDNS" . ".txt")


Codice:
# Internal processing below...

Codice:
# ----------------------------------

Codice:
:local ipv4addr


Codice:
# Get WAN interface IP address

Codice:
:set ipv4addr [/ip address get [/ip address find interface=$WANinterface] address]

Codice:
:set ipv4addr [:pick [:tostr $ipv4addr] 0 [:find [:tostr $ipv4addr] "/"]]


Codice:
:if ([:len $ipv4addr] = 0) do={

Codice:
  :log error ("Could not get IP for interface " . $WANinterface)

Codice:
  :error ("Could not get IP for interface " . $WANinterface)

Codice:
}


Codice:
:log info ("Updating DDNS IPv4 address" . " Client IPv4 address to new IP " . $ipv4addr . "...")


Codice:
/tool fetch url="http://$ddnshost:$key@$updatehost/nic/update?hostname=$ddnshost&myip=$ipv4addr"  \

Codice:
dst-path=$outputfile

Codice:
                             

Codice:
:log info ([/file get ($outputfile) contents])

Codice:
/file remove ($outputfile)


The above script works with ROS 3.x. For the 5.x a minor modification for the fetch command is needed:
Codice:
/tool fetch mode=http url="http://$ddnshost:$key@$updatehost/nic/update?hostname=$ddnshost&myip=$ipv4addr" \

Codice:
dst-path=$outputfile