Mikrotik Dynamic

From My Notepad
Jump to: navigation, search

Updating an ip address to a resolved address

The following script is setup for ovpn-client interfaces and has no error checking:

:local lookupAddress "dynamic.address.com";
:local interfaceName "interface-name";

:local interfaceID [/interface find name="$interfaceName"];

:local resolvedIP [:resolve "$lookupAddress"];
:local currentIP [/interface ovpn-client get $interfaceID connect-to];
       
:if ($resolvedIP != $currentIP) do={
   /interface ovpn-client set $interfaceID connect-to=$resolvedIP;
   /log info "interface $interfaceName connect-to address updated";
}