Enabling OpenWRT’s NTP Server

Normally, I configure my systems to synchronize their clocks over NTP to one of the NTP Pool servers. However, due to the load-balanced nature of the NTP Pool, clients must use fully qualified domain names in order to synchronize with NTP Servers. Most of the time, this isn’t a problem – most NTP clients fully support using FQDNs as opposed to IPs. However, a minority of clients, usually those in embedded hardware, only allow IPs to be used.

I don’t want to hardcode an external NTP server IP in to these systems, so I need a local NTP server on my network. OpenWRT’s NTP client already synchronizes with the NTP pool, so making it also act as a NTP server for internal clients is ideal. OpenWRT’s default client is the busybox NTP client, which can also act as a server – no need to install additional packages! However, by default OpenWRT only enables it as a client and not a server, but activating the server is rather simple.

  1. Edit /etc/config/system . Unfortunately, the NTP server isn’t configurable via the web interface so you’ll have to use the command line.
  2. Find the config timeserver ‘ntp’ section. Underneath the existing NTP server configuration add the configuration option option enable_server ‘1’ . Save the file and quit.
  3. Restart the NTP service using the command /etc/init.d/sysntpd restart .
  4. Done! OpenWRT will now act as a local timeserver.

To verify that the server really is active, you can grep  the output of ps for ntpd . If the configuration was applied successfully, ntpd  should have be running with the -l  flag. Using another system, you could also query it using ntpdate -q hostname , which will query the server and tell you the current offset of your local clock.

Although this won’t be as accurate as synchronizing directly with one of the NTP Pool servers, it should be more than accurate enough for most needs – with sub-second accuracy.

This was tested on OpenWRT Chaos Calmer 15.05, but should work with OpenWRT Backfire 10.3.1 onwards as per the documentation.

You may also like...

2 Responses

  1. kirchnet says:

    It looks like you need to set the client to port 123 when listening to the NTP UDP package from OpenWRT. Is that correct?

  2. Vegz78 says:

    Worked like a charm, thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *