Difference between revisions of "NTPD"

From IPLOG
Jump to: navigation, search
 
(13 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
== Description ==
 
== Description ==
 
The '''NTPD''' program is an operating-system daemon that sets and maintains a computer system's time in synchronization with Internet-standard time servers. It is a complete implementation of the Network Time Protocol (NTP) version 4, but retains compatibility with versions 1, 2, and 3 as defined by RFC 1059, RFC 1119, and RFC 1305, respectively. ntpd performs most computations in 64-bit floating point arithmetic and uses 64-bit fixed point operations only when necessary to preserve the ultimate precision, about 232 picoseconds. While ordinary workstations and networks cannot achieve the ultimate precision as of 2015, future processors and networks may require it.
 
The '''NTPD''' program is an operating-system daemon that sets and maintains a computer system's time in synchronization with Internet-standard time servers. It is a complete implementation of the Network Time Protocol (NTP) version 4, but retains compatibility with versions 1, 2, and 3 as defined by RFC 1059, RFC 1119, and RFC 1305, respectively. ntpd performs most computations in 64-bit floating point arithmetic and uses 64-bit fixed point operations only when necessary to preserve the ultimate precision, about 232 picoseconds. While ordinary workstations and networks cannot achieve the ultimate precision as of 2015, future processors and networks may require it.
 +
 +
  
 
== NTPD Installation ==
 
== NTPD Installation ==
 
To install '''NTPD package''' simply use the following commands:
 
To install '''NTPD package''' simply use the following commands:
 +
  
  
Line 19: Line 22:
  
 
=== 2. Choose one of the available packages ===
 
=== 2. Choose one of the available packages ===
==== [[NTPD#3. Install NTPD Package|ntpd]] ====
+
'''metel-ntpd-server-internet'''
- server package with linux default configuration
+
- NTP server, package contains configuration as  [[NTPD#2. With Connetion to Remote NTP Servers|"Synchronization to two internet NTP servers"]] (synchronization to internet NTP servers).
  
 +
'''metel-ntpd-standalone-server'''
 +
- NTP server, package contains configuration as  [[NTPD#1. Standalone NTP server|"Standalone NTP server"]] (without synchronization to internet NTP servers).
  
==== [[NTPD#2. With Connetion to Remote NTP Servers|metel-ntpd-server-internet]] ====
+
'''ntpd'''
- server package contains configuration as "Synchronization to two internet NTP servers"
+
- NTP server, package with  [[NTPD#3. Install NTPD Package|"Linux default configuration"]].
  
  
==== [[NTPD#1. Standalone NTP server|metel-ntpd-standalone-server]] ====
 
- server package contains configuration as "Standalone NTP server"
 
  
 +
=== 3. Install NTPD Packages ===
 +
==== a) metel-ntpd-server-internet ====
 +
{{NotePre|text= root@iplog:~# opkg install metel-ntpd-server-internet
 +
}}
 +
 +
Example of Package Installing:
 +
Installing metel-ntpd-server-internet (0.0.1-12326) on root.
 +
Downloading http://www.iplog.eu/opkg/base/metel-ntpd-server-internet_0.0.1-12326_all.ipk.
 +
Installing ntpd (4.2.8p9-12326) on root.
 +
Downloading http://www.iplog.eu/opkg/base/ntpd_4.2.8p9-12326_all.ipk.
 +
Stopping ntpd: FAIL
 +
Configuring ntpd.
 +
Starting ntpd: OK
 +
Configuring metel-ntpd-server-internet.
 +
Restarting ntpd:
 +
Stopping ntpd: OK
 +
Starting ntpd: OK
 +
After installation the NTPD daemon automatically starts.
 +
 +
 +
==== b) metel-ntpd-standalone-server ====
 +
{{NotePre|text= root@iplog:~# opkg install metel-ntpd-standalone-server
 +
}}
 +
 +
Example of Package Installing:
 +
Installing metel-ntpd-standalone-server (0.0.1-12326) on root.
 +
Installing ntpd (4.2.8p9-12326) on root.
 +
Stopping ntpd: FAIL
 +
Configuring ntpd.
 +
Starting ntpd: OK
 +
Configuring metel-ntpd-standalone-server.
 +
Restarting ntpd:
 +
Stopping ntpd: OK
 +
Starting ntpd: OK
 +
After installation the NTPD daemon automatically starts.
  
  
=== 3. Install NTPD Package ===
+
==== c) ntpd ====
 
{{NotePre|text= root@iplog:~# opkg install ntpd
 
{{NotePre|text= root@iplog:~# opkg install ntpd
 
}}
 
}}

Latest revision as of 09:47, 14 January 2022

NTPD (Network Time Procokol Daemon)

Description

The NTPD program is an operating-system daemon that sets and maintains a computer system's time in synchronization with Internet-standard time servers. It is a complete implementation of the Network Time Protocol (NTP) version 4, but retains compatibility with versions 1, 2, and 3 as defined by RFC 1059, RFC 1119, and RFC 1305, respectively. ntpd performs most computations in 64-bit floating point arithmetic and uses 64-bit fixed point operations only when necessary to preserve the ultimate precision, about 232 picoseconds. While ordinary workstations and networks cannot achieve the ultimate precision as of 2015, future processors and networks may require it.


NTPD Installation

To install NTPD package simply use the following commands:


1. Update List of Available Packages

root@iplog:~# opkg update

Example of Update Process:

Downloading http://www.iplog.eu/opkg/base/Packages.gz.
Updated source 'base'.
Downloading http://www.iplog.eu/opkg/firmware/Packages.gz.
Updated source 'firmware'.


2. Choose one of the available packages

metel-ntpd-server-internet - NTP server, package contains configuration as "Synchronization to two internet NTP servers" (synchronization to internet NTP servers).

metel-ntpd-standalone-server - NTP server, package contains configuration as "Standalone NTP server" (without synchronization to internet NTP servers).

ntpd - NTP server, package with "Linux default configuration".


3. Install NTPD Packages

a) metel-ntpd-server-internet

root@iplog:~# opkg install metel-ntpd-server-internet

Example of Package Installing:

Installing metel-ntpd-server-internet (0.0.1-12326) on root.
Downloading http://www.iplog.eu/opkg/base/metel-ntpd-server-internet_0.0.1-12326_all.ipk.
Installing ntpd (4.2.8p9-12326) on root.
Downloading http://www.iplog.eu/opkg/base/ntpd_4.2.8p9-12326_all.ipk.
Stopping ntpd: FAIL
Configuring ntpd.
Starting ntpd: OK
Configuring metel-ntpd-server-internet.
Restarting ntpd:
Stopping ntpd: OK
Starting ntpd: OK

After installation the NTPD daemon automatically starts.


b) metel-ntpd-standalone-server

root@iplog:~# opkg install metel-ntpd-standalone-server

Example of Package Installing:

Installing metel-ntpd-standalone-server (0.0.1-12326) on root.
Installing ntpd (4.2.8p9-12326) on root.
Stopping ntpd: FAIL
Configuring ntpd.
Starting ntpd: OK
Configuring metel-ntpd-standalone-server.
Restarting ntpd:
Stopping ntpd: OK
Starting ntpd: OK

After installation the NTPD daemon automatically starts.


c) ntpd

root@iplog:~# opkg install ntpd

Example of Package Installing:

Installing ntpd (4.2.8p9-9671.212083251) on root.
Downloading http://www.iplog.eu/opkg/base/ntpd_4.2.8p9-9671.212083251_all.ipk.
Configuring ntpd.

When the instalation is complete, start the NTP daemon by command:

root@iplog:~# /etc/init.d/S49ntp start


Note: Every time the configuration file /etc/ntp.conf is changed, restart the service S49ntp by command /etc/init.d/S49ntp restart!



Configuration Examples

This section provides several examples of the /etc/ntp.conf configuration file.

1. Standalone NTP server

The following configuration has the following features:

- Local NTP server with specified stratum 10
- No synchronization to internet NTP servers


Editing Configuration File Command:

root@iplog:~# vi /etc/ntp.conf

File content:

restrict default
#restrict source
#interface listen wildcar
 
# create a local NTP server
server 127.127.1.0
fudge 127.127.1.0 stratum 10

driftfile /tmp/ntp.drift


2. With Connetion to Remote NTP Servers

The example shows the optimal configuration for the Czech Republic.

This configuration has the following features:

- Local NTP server with specified stratum 10
- Synchronization to two internet NTP servers


Editing Configuration File Command:

root@iplog:~# vi /etc/ntp.conf

File Content:

restrict default
#restrict source
#interface listen wildcard

server tik.cesnet.cz
server tak.cesnet.cz

server 127.127.1.0
fudge 127.127.1.0 stratum 10 refid ILOG

driftfile /tmp/ntp.drift
#end-of-file


Diagnostics

NTPQ

The ntpq utility program is used to query NTP servers which implement the recommended NTP mode 6 control message format about the current state and to request changes in that state.

NTPQ Home Page


Example:

root@iplog:~# watch ntpq -p -n

NTPQ Parameters:

watch - Every 2s: ntpq -p -n
-p - Print current status
-n - Disable DNS resolving
Every 2s: ntpq -p -n                                        2019-08-01 10:00:12

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 127.127.1.0     .ILOG.          10 l  41m   64    0    0.000    0.000   0.000
+195.113.144.201 195.113.144.238  2 u   92  128  377   12.307    2.212   1.333
*195.113.144.238 .GPS.            1 u   20  128  377   11.039    4.785   1.630


This section is a copy from https://pthree.org/2013/11/05/real-life-ntp/.

Parameters:

remote – The remote server you wish to synchronize your clock with
◦ " " Discarded as not valid. It is possible that you will be unable to communicate with the remote machine (it's not online), this time source is a ".LOCL." refid time source, it's a high stratum server, or the remote server is using this computer as an NTP server.
◦ "x" Discarded by the intersection algorithm.
◦ "." Discarded by table overflow (not used).
◦ "-" Discarded by the cluster algorithm.
◦ "+" Included in the combined algorithm. This is a good candidate if the current server we are synchronizing with is discarded for any reason.
◦ "#" Good remote server to be used as an alternative backup. This is only shown if you have more than 10 remote servers.
◦ "*" The current system peer. The computer is using this remote server as its time source to synchronize the clock
◦ "o" Pulse per second (PPS) peer. This is generally used with GPS time sources, although any time source delivering a PPS will do. This tally code and the previous tally code "*" will not be displayed simultaneously.
refid – The upstream stratum to the remote server. For stratum 1 servers, this will be the stratum 0 source.
st – The stratum level, 0 through 16.
t – The type of connection.
◦ l = local reference clock
◦ u = unicast (most common)
◦ m = multicast
◦ b = broadcast
when – The last time when the server was queried for the time. Default is seconds, or "m" will be displayed for minutes, "h" for hours and "d" for days.
poll – How often the server is queried for the time, with a minimum of 8 seconds to a maximum of 36 hours. It's also displayed as a value from a power of two. Typically, it's between 64 seconds and 1024 seconds.
reach – This is an 8-bit left shift octal value that shows the success and failure rate of communicating with the remote server. Success means the bit is set, failure means the bit is not set. 377 is the highest value.
delay – This value is displayed in milliseconds, and shows the round trip time (RTT) of your computer communicating with the remote server.
offset – This value is displayed in milliseconds, using root mean squares, and shows how far off your clock is from the reported time the server gave you. It can be positive or negative.
jitter – This number is an absolute value in milliseconds, showing the root mean squared deviation of your offsets.