NTP client/ NTP server
Note: very few of the devices supported by OpenWrt have a hardware clock.
You can set the system time using one of the following methods:
- Manually. Set the system date and time using busybox-date via
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]
- NTP (Network Time Protocol. Automatic using busybox-ntpd. (configured in system.ntp (/etc/config/system)). The NTP Daemon (ntpd) can be configured to run as a client and/or server. (See below).
- Time Protocol (Time Protocol). Obsolete Use rdate (busybox-rdate) to set the time:
rdate -s time.protocol.server.org
Use with/etc/crontabs/root
- 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.
Installation (Alternative NTP packages
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.
Example (install the ntpd package, (not busy box-ntp):
opkg update opkg install ntpd /etc/init.d/ntpd enable /etc/init.d/ntpd start netstat -a
A ntpd server should be listening on the default NTP port (123).
Configuration
- The busybox-ntpd is configured in
/etc/config/system.
By default, it 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.
- The package
ntpclientis configured in/etc/config/ntpclient.
ntpdate is a command line tool that usually is used for one time synchronizations:
ntpdate pool.ntp.organd 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.
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.
Troubleshooting
Notes
doc/howto/ntp.client.txt · Last modified: 2012/01/16 13:04 by cire831