I have a problem with the NTP client on my Mikrotik, and I know this topic has been discussed several times.
To the point: the IPS provider is blocking any traffic on UDP port 123.
I have a NAS server and several other devices behind the Mikrotik, which uses a NTP client with the NTP server pool.ntp.org (for ex.).
All of them are syncing the time correctly. When it’s working on this devices, why can’t my Mikrotic sync it?
Then likely the issue is connected with your router (firewall or whatever) settings. (If other devices have NTP working it cannot be the ISP blocking port 123 or similar).
When you already know the problem is that your ISP filters port 123, it should not be difficult to find the well known workaround for that here on the forum…
(add a NAT rule that translates the source port for outgoing NAT requests to something else than 123)
Sure it would be convenient when there was some option in the NTP client to use a random source port number instead of 123, but there isn’t.
My ISP blocks inbound UDP packets on port 123 on both IPv4 and IPv6 too (with the exception of a few whitelisted IPv4 addresses from a national NTP service - ntp.br).
RouterOS’ NTP client as well as Windows’ NTP client both use the source port 123 when performing their NTP requests. With that, the response from the server comes with the destination port 123 and gets blocked by my ISP.
To work around that, I’ve simply created two source NAT rules (one for IPv4 and one for IPv6) to change the source ports of the requests to ones on the dynamic/ephemeral range.
IPv4 rule (must come before the all-encompassing source NAT or masquerade rule):
So all the devices behind the Mikrotik router were already using non-123 ports?
I did not get that the ISP blocking Port 123 was an established fact, my bad.
Happy that the issue was solved.
Can one then conclude that RoS is hardwired to use the standard 123 port for outgoing NTP traffic but NTP servers on the internet will accept any port ???
Yes, RouterOS uses source port 123, by their choice, when the NTP client is performing NTP requests (and so the response comes with destination port 123), but NTP servers don’t care about the source port. Only about the destination port, of course, which must be 123.
Perhaps MikroTik went this way for symmetry and ease of firewalling (by using port 123 both ways). Who knows? Windows also uses source port 123 for some reason (and they are still using NTP v3 - yikes).
NTP uses port 123 for both source and destination port when running in peer-to-peer mode (Mode 1 & 2). ROS probably does it for mode 3 (client-server) as well to keep thing simple.
The following text from Section 9.1 (Peer Process Variables) of [RFC5905]:
dstport:
UDP port number of the client, ordinarily the NTP port number PORT (123) assigned by the IANA. This becomes the source port number in packets sent from this association.
is replaced with:
dstport:
UDP port number of the client. In the case of broadcast server mode (5) and symmetric modes (1 and 2), it SHOULD contain the NTP port number PORT (123) assigned by IANA. In the client mode (3), it SHOULD contain a randomized port number, as specified in [RFC6056]. The value in this variable becomes the source port number of packets sent from this association. The randomized port number SHOULD NOT be shared with other associations, to avoid revealing the randomized port to other associations.
Interesting so the Randomized port SourceNAT rule is our work around user method of conforming to the standard while MT sits on their thumbs… eyes glazed over, overdosed on some Latvian candy