Hello!
My RB450G (RouterOS v6.10) is configured as an NTP client. I would like to use an FQDN (pool.ntp.org, europe.pool.ntp.org, etc) to respect load-balancing. How can I do this?
Thanks in advance!
It performs the DNS resolution precisely once: the moment you configure it, and then never again. Load balancing (the whole point of pool.ntp.org) is lost. This is not a solution, unfortunately.Just input the FQDN in the /system ntp
The FQDN will be converted to IP addresses once the router does nslookup.
#get ntp ip's
:local ntpipa [:resolve 0.us.pool.ntp.org];
:local ntpipb [:resolve 1.us.pool.ntp.org];
:local cn;
#get current ip's
:local ntpcura [/system ntp client get primary-ntp];
:local ntpcurb [/system ntp client get secondary-ntp];
#change primary if needed
:if ($ntpipa != $ntpcura) do={
#:log info "Changing primary NTP ($ntpcura --> $ntpipa)";
/system ntp client set primary-ntp="$ntpipa";
:set cn "1";
}
#change secondary if needed
:if ($ntpipb != $ntpcurb) do={
#:log info "Changing secondary NTP ($ntpcurb --> $ntpipb)";
/system ntp client set secondary-ntp="$ntpipb";
:set cn "1";
}
:if ($cn != "1") do={
#:log info "No NTP updates required";
}
#:log info "Finished updating NTP IP's";
What a hack, but if need be, I'll do it. Please excuse the ignorance; how exactly is this added and scheduled?I use a script set to run every 30 min to update the settings with the new addresses to respect the load balancing.
/system script run check-time
This doesn't seem to work; here's the script:I wish ros would save the fqdn instead of the ip. I use a script set to run every 30 min to update the settings with the new addresses to respect the load balancing.
:log info "NTP IP update script triggered.";
#Get NTP IPs
:local ntpipa [:resolve 0.europe.pool.ntp.org];
:local ntpipb [:resolve 1.europe.pool.ntp.org];
:local cn;
#Get Current IPs
:local ntpcura [/system ntp client get primary-ntp];
:local ntpcurb [/system ntp client get secondary-ntp];
#change primary if needed
:if ($ntpipa != $ntpcura) do={
:log info "Changing primary NTP IP ($ntpcura --> $ntpipa)";
/system ntp client set primary-ntp="$ntpipa";
:set cn "1";
}
#change secondary if needed
:if ($ntpipb != $ntpcurb) do={
:log info "Changing secondary NTP IP ($ntpcurb --> $ntpipb)";
/system ntp client set secondary-ntp="$ntpipb";
:set cn "1";
}
:if ($cn != "1") do={
:log info "No NTP updates required";
}
:log info "Finished updating NTP IP addresses";
echo: script,info NTP IP update script triggered.
A nice clean solution. Thank you!Why complicate all????
You just need this:
this update ntp servers each 30 min [and start to do it after 2 min from RB is powered].Code: Select all/system scheduler add interval=30m name=check_time_servers on-event="/system ntp client set enabled=yes mode=unicast primary-ntp=[:resolve 0.europe.pool.ntp.org] secondary-ntp=[:resolve 1.europe.pool.ntp.org];" policy=read,write start-date=jan/02/1970 start-time=00:02:00