From charlesreid1

NTP = network time protocol

Why It Is Important

The "it" here refers to two things - time, and the time server.

Why Time Is Important

Timing is important to many Linux functions, like DHCP leases or file synchronization.

Why Time Server Is Important

If you are running a large network with hundreds of computers, each of those computers will be looking for a network time protocol server. If they don't find one, each of those computers will go to a public time server and ask for the time. So it is a courtesy to set up your own network time server, and ask a public server for the time once and only once for your entire network.

Set Up NTP

Install

To install a network time protocol server:

$ apt-get install ntp

Now start the ntp daemon:

$ systemctl start ntpd

Configure

To configure NTP, you will modify /etc/ntp.conf

Give the addresses of some public time servers:

server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org

Restrict the DNS configuration so no users on certain subnets can modify it:

restrict 10.10.96.0 mask 255.255.252.0 nomodify notrap

Also add a log file:

logfile /var/log/ntp.log

Check this file if there are any issues with the NTP.

If you have a firewall, be sure and add a rule to let NTP traffic through. Alternatively, you can open port 123.

View

To see information about the time server:

$ ntpq -p

Here is info about what the output means:

  • Remote column - the name of any remote NTP server
  • Refid column - the IP of the remote machine
  • St column - stratum, which is a measure of how close the time server is to you (physically)
  • When column - shows how many seconds ago the server was polled
  • Poll column - polling frequency
  • Reach - whether the time server was reached in the last 8 attempts (377 means yes to all 8 attempts)
  • Delay - delay time in ms of the time server
  • Offset - difference between local and remote clock


Once you have set up a network time server, it will take as long as 30 minutes for computers on the network to start to see it. To verify the time server is synchronizing correctly with the network time server you set up, run the above command on a system:

$ ntpq -p

If everything is working correctly, it should list 10.10.99.X (or whatever IP address the time server is at).




Related

See Template:LinuxNetworkingFlag