I have a few VLANs and would like to use OpenWRT as the NTP server, I found the wiki that lets you enable it by commandline but can we do it from luci?
Under System > Time Sync tab > Provide NTP server > enable is enough for all interfaces or would I need to setup firewall rules for the VLANs?
Yes, enabling the NTP server as you described will be enough in general, but there are two other things that need to be considered:
If you want to advertise your OpenWrt router as the NTP server via DHCP, add DHCP option 42 with the address of the router.
The other factor you must consider is your firewall. If any of your VLANs are associated with zones/rules that prohibit router INPUT, you will need to add a rule to accept the NTP traffic (UDP port 123).
The firewall (not DHCP) controls the 'allow' part of the equation.
If you advertise the NTP server via DHCP, your client devices will be aware of (and hopefully choose to use) your router as their NTP server. If you do not advertise it, the clients won't be aware unless you manually set the NTP server in the respective configurations (I.e. on the clients/hosts themselves in their time settings).
Doubt there are many devices in reality that will care about a “DHCP option 42”.
All network equipment even with the smallest level of self respect (routers, switches, ap, etc) always has the NTP servers either preset to call home or they are set manually.
And the rest of clients on a network seems to call home without choice where ever in the world that ntp server is.
So, I've enabled the NTP server and allowed UDP port 123 from my VLAN to the router but it still does not work. I have one rule for DHCP and DNS, modified it to allow NTP.
Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </> " button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have:
Set the destination zone as input (this device). And note that you're only intercepting NTP traffic that is originating from the lan.
Keep in mind that the NTP hijacking is a different thing than having a running server. The former will only work properly if the server is up, so work on verifying that the server works from the desired network(s) when you actively set it as the NTP server on a device that will honor that configuration.
The firewall rule was correct, and it is working. I was just rebooting the client to force the clock to reset but didn't wait long enough for the sync to occur.