Ntpclient configuration

The ntpclient configuration file defines parameters for the ntpclient program, a small daemon that will keep the local clock in sync with time servers on the internet.

The configuration file consists of a section defining general daemon options, a section defining clock drift information, and one or more sections defining time server hosts to use.

The ntpclient section defines general daemon options. This is the default configuration for this section:

config 'ntpclient'
        option 'interval' '600'

The ntpclient section contains these settings:

Name Type Required Default Description
count integer no 0 Number of time measurements to perform before exiting. 0 means to never stop.
interval integer no 600 Seconds to pause between measurements, i.e. 10 minutes. It is usually neither necessary not helpful to reduce this number.
interface text no (none) Default value for setting interface in host section.

The ntpdrift section defines parameters to adjust the drift of the local clock so that it can run more accurately. Please see the ntpclient HOWTO on how to compute these parameters.

This is the default configuration for this section:

config 'ntpdrift'
        option 'freq' '0'

The ntpclient section contains these settings:

Name Type Required Default Description
freq integer no (none) Frequency adjustment for the local clock.

To receive time, at least one host must be configured through a host section. OpenWrt will try the specified hosts in order, and use the first one that is responding to time requests. OpenWrt uses the NTP Pool to locate a close-by time server.

These are the default hosts:

config 'ntpserver'
        option 'hostname' '0.openwrt.pool.ntp.org'
        option 'port'     '123'
 
config 'ntpserver'
        option 'hostname' '1.openwrt.pool.ntp.org'
        option 'port'     '123'
 
config 'ntpserver'
        option 'hostname' '2.openwrt.pool.ntp.org'
        option 'port'     '123'
 
config 'ntpserver'
        option 'hostname' '3.openwrt.pool.ntp.org'
        option 'port'     '123'

A host section contains these settings:

Name Type Required Default Description
hostname string yes (none) Hostname of the NTP server.
port integer no 123 Port number the NTP server is listening on.
interface text no (none) Only test this host if the specified interfaces comes up.

The ntpclient is started via the hotplug subsystem upon any network interface startup, see /etc/hotplug.d/iface/20-ntpclient. The script starts the daemon in 4 phases:

  1. preliminary test - the script checks if the ntpclient is already running.
  2. drift - the scripts sets the specified drift in system clock.
  3. ntp server check phase - the script tests the reachability of the ntp servers (hosts) from config file (uses the ntpclient for this). The script only checks hosts where the specified interface (or inherited interface from ntpclient section) matches the interface that triggered hotplug.d or where no interface is specified at all. If no ntp server is reachable the script quits.
  4. operational phase - the ntpclient is started with the first reachable host and user configuration options (interval etc.) of polling and time adjustment

All instances of the ntpclient are killed via the hotplug subsystem upon any network interface shutdown, see /etc/hotplug.d/iface/20-ntpclient.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/08/02 19:44
  • by vgaetera