NTP client/ NTP server

Note: most devices supported by OpenWrt do not have a hardware clock.

You can set the system date and time using one of the following methods:

  • Manually by utilizing busybox-date, e.g.
    date -s  hh:mm[:ss] or [YYYY.]MM.DD-hh:mm[:ss] or YYYY-MM-DD hh:mm[:ss] or [[[[[YY]YY]MM]DD]hh]mm[.ss]
  • Network Time Protocol by invoking busybox-ntpd once, e.g.:
    ntpd -q -p ptbtime1.ptb.de
    , or configure /etc/config/system accordingly to have nptd run as NTP client (and optionally additionally as NTP server) daemon. By default busybox-ntpd runs as a client and does not serve time. A server can be enabled by adding the flag "-l" to "local args" in /etc/init.d/sysntpd (line 23). This will most likely become configurable in a release post Backfire 10.3.1.
  1. Other NTP packages If the default busybox-ntpd isn't sufficient, one of the following alternate ntpd packages can be installed:
Name Version Size Description
ntpclient 2007_365-4 12.970 NTP client for setting system time from NTP servers.
ntpd 4.2.6p4-1 168.021 The ISC ntp suite is a collection of tools used to synchronize the system clock with remote NTP time servers and run/montior local NTP servers. This package contains the ntpd server. See ntpd
ntpd-ssl 4.2.6p4-1 179.511 The ISC ntp … . This package contains the ntpd server with OpenSSL support.
ntpdate 4.2.6p4-1 36.642 The ISC ntp … . This package contains ntpdate. See ntpdate
ntp-utils 4.2.6p4-1 158.035 The ISC ntp … . This package contains ntpdc and ntpq.

NTP (Network Time Protocol) is used to keep computer clocks accurate by synchronizing them over the Internet or a local network, or by following an accurate hardware receiver that interprets GPS, DCF-77, NIST or similar time signals.

This package contains the NTP daemon and utility programs. An NTP daemon needs to be running on each host that is to have its clock accuracy controlled by NTP. The same NTP daemon is also used to provide NTP service to other hosts.

In R28612 and R28613 busybox-rdate has been replaced with busybox-ntpd by default.
If you check the entire file Config.in not only the diffs above, you will learn that busybox-ntpd is employable as server as well by default.

The busybox-ntpd will auto-tune its sync rate depending on clock drift and other factors, it varies between 1-60min, and yes its a daemon which keeps syncing the time. When invoking it with -q it would act like ntpdate, means do a burst poll/sync cycle and exit.


See opkg for more details on using the OpenWrt package manager.

By default, busybox-ntpd, can supply both a client for setting time, and a server for supplying time to the local net. This is installed out of the box and should take care of most time syncing needs. It doesnt support advanced features like query, so the server cannot be monitored from other systems like Nagios.

Example (install the real ntpd package (=not busybox-ntpd):

opkg update
opkg install ntpd
/etc/init.d/sysntpd disable
/etc/init.d/ntpd enable
/etc/init.d/ntpd start
netstat -l | grep ntp

When you use ntpd, make sure you disable sysntpd daemon. A ntpd server should be listening on the default NTP port (UDP 123).


By default, it runs as a client and does not serve time to other peers. A server can be enabled by adding the flag "-l" to "local args" in /etc/init.d/sysntpd (line 23). Starting with Backfire 10.3.1 this is not anymore needed and can be also changed in /etc/config/system.

ntpdate is a command line tool that usually is used for one time synchronizations with remote ntp peers:

ntpdate pool.ntp.org
and also in conjuction with /etc/crontabs/root

  • ntpd is a daemon that runs all the time in the background for permanent synchronization.

According to Debian the same NTP daemon is also used to provide NTP service to other hosts.

To use ntpd as NTP client daemon, no change to the firewall is required, to run as NTP server daemon, open port 123 UDP for your NTP clients (which is by default open in LAN). An example to run ntpd as a server:

driftfile  /var/lib/ntp/ntp.drift

server 0.openwrt.pool.ntp.org iburst
server 1.openwrt.pool.ntp.org iburst
server 2.openwrt.pool.ntp.org iburst
server 3.openwrt.pool.ntp.org iburst

#exchange time with everybody but dont allow configuration (noquery to forbid query)
restrict -4 default kod notrap nomodify nopeer
restrict -6 default kod notrap nomodify nopeer

#local users may interrogate the ntp server more closely
restrict ::1

rdate server

First of all: rdate is old, very simple and does not give you highly reliable time. If you still want to run a server for rdate clients for some reason you can use the xinetd package.

After installing xinetd and running "/etc/init.d/xinetd enable", create a file "/etc/xinetd.d/time-stream" with the following content:

service time
	disable = no
	id		= time-stream
	type		= INTERNAL
	wait		= no
	socket_type	= stream
	flags		= IPv4
Finally run "/etc/init.d/xinetd restart" and your rdate-timeserver should be up and running.



Back to top

doc/howto/ntp.client.txt · Last modified: 2013/02/24 18:42 by ghost