Thursday, June 8, 2017

Configure NTP Client(Linux) to Synchronize with NTP Server

Configure NTP Client(Linux) 

1. Modify ntp.conf on NTP Client
This setup should be done on your NTP Client (Not on NTP-server)
To synchronize the time of your local Linux client machine with NTP server, edit the /etc/ntp.conf file on the client side. Here is an example of how the sample entries looks like. In the following example, you are specifying multiple servers to act as time server, which is helpful when one of the timeservers fails.

server 0.rhel.pool.ntp.org=iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst

iburst: After every poll, a burst of eight packets is sent instead of one. When the server is not responding, packets are sent 16s interval. When the server responds, packets are sent every 2s.
Edit your NTP.conf to reflect appropriate entries for your own NTP server.

server 19.168.1.1 prefer

prefer: If this option is specified that server is preferred over other servers. A response from the preferred server will be discarded if it differs significantly different from other server’s responses.

2. Start the NTP Daemon
Once the ntp.conf is configured with correct settings, start the ntp daemon.

/etc/init.d/ntp start

You will see the NTP will slowly start to synchronize the time of your linux machine with the NTP Server.

3. Check the NTP Status
Check the status of NTP using the ntpq command. If you get any connection refused errors then the time server is not responding or the NTP daemon/port is not started or listening.

# ntpq -p

remote refid st t when poll reach delay offset jitter
===================================================
*elserver1 19.168.1.1 3 u 300 1024 377 1.225 -0.071 4.606

4. Set Local Date and Time
The ntpdate command can be used to set the local date and time by polling the NTP server. Typically, you’ll have to do this only one time.
Your jitter value should be low, else check the drift from the clock in the driftfile. You may also need to change to some other NTP server based on the difference. This command synchronizes the time with your NTP server manually.

# ntpdate –u 19.168.1.1

After this initial sync, NTP client will talk to the NTP server on an on-going basis to make sure the local time reflects the accurate time.
You can also use the following command to get the current status of ntpd.

# ntpdc -c sysinfo
system peer: thegeekstuff.com
system peer mode: client
leap indicator: 00
stratum: 4
precision: -23
root distance: 0.00279 s
root dispersion: 0.06271 s
reference ID: [19.168.1.1]
reference time: d70bd07b.f4b5cf2b Wed, Apr 30 2014 15:41:47.955
system flags: auth monitor ntp kernel stats
jitter: 0.000000 s
stability: 0.000 ppm
broadcastdelay: 0.000000 s
authdelay: 0.000000 s

No comments:

Post a Comment