Ho To Resolve host-name - Mikrotik Script RouterOS
Many users are asking feature to use dns names instead of IP address for radius servers, firewall rules, etc.
So here is an example how to resolve RADIUS server's IP.
Lets say we have radius server configured:
/radius
add address=3.4.5.6 comment=myRad
And here is a script that will resolve ip address, compare resolved ip with configured one and replace if not equal:
/system script add name="resolver" source= {
:local resolvedIP [:resolve "server.example.com"];
:local radiusID [/radius find comment="myRad"];
:local currentIP [/radius get $radiusID address];
:if ($resolvedIP != $currentIP) do={
/radius set $radiusID address=$resolvedIP;
/log info "radius ip updated";
}
}
# Add this script to scheduler to run for example every 5 minutes
/system scheduler add name=resolveRadiusIP on-event="resolver" interval=5m
Credit: wiki.mikrotik.com