User Tools

Site Tools


kb:ni-rt:linuxrt:ntp

10 Network Time Protokoll (NTP)

On systems with NI Linux RT the NTP daemon can be installed with the package manager.

opkg install ntp

Other related packages which may be useful: ntp-utils ntp-doc ntpdate ntp-dbg ntp-tickadj

Configuration

To configure the NTP daemon open the file /etc/ntp.conf with an editor like vi or nano. The default configuration can work as it is and contains the addresses to a few timeservers hosted by NI. Because the NI time server are probably located in the US it is recommended to adopt the list to more local time servers, e.g.:

  • 0.de.pool.ntp.org … 3.de.pool.ntp.org (https://www.pool.ntp.org/de/)
  • de.pool.ntp.org (only German time servers)
  • ptbtime1.ptb.de, ptbtime2.ptb.de, ptbtime3.ptb.de (Physikalisch-Technische Bundesanstalt)

Permissions

The default configuration permits only the local host to access the NTP daemon. This is sufficient if the system is intended to act only as an client. If the system should also act as a server for other systems not connected with the internet a line in the following format is required.

restrict 192.0.2.0 mask 255.255.255.0 nomodify notrap nopeer

This allows all clients in the given subnet to query the time and statistics.

Example Configuration with Permission for Clients in Subnet

# Default config file used for ntpd and sntp on NI Linux RT
 # Panic threshold
# Checks if the offset is greater than this and exits if it is,
# believing something is horribly wrong.
# When set to 0, disables sanity check and will accept any time.
tinker panic 0
 # By default, the server allows:
# - all queries from the local host
# - only time queries from remote hosts, protected by rate limiting and kod
 # Prevent access to everything not explicitly allowed; we only want to
# answer time queries from servers.
restrict default kod limited nomodify nopeer noquery notrap
 # Permit standard loopback addresses because some applications may
# require them.
restrict 127.0.0.1
restrict ::1
 # Permit clients in the subnet to query the time.           
restrict 10.21.31.0 mask 255.255.255.0 nomodify notrap nopeer
 # By default, NTP doesn't use a drift file            
# Specifying the file will enable the drift file option
driftfile /var/lib/ntp/drift
 # Servers              
server 0.de.pool.ntp.org
server 1.de.pool.ntp.org
server 2.de.pool.ntp.org

References

kb/ni-rt/linuxrt/ntp.txt · Last modified: 2024/08/02 17:18 by joerg.hampel