NTP Server Configuration in Linux

NTP : Network Time Protocol is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in current use. NTP was designed by David L. Mills of the University of Delaware.

How does NTP work?

The NTP client initiates a time-request exchange with the NTP server. As a result of this exchange, the client is able to calculate the link delay and its local offset, and adjust its local clock to match the clock at the server’s computer. As a rule, six exchanges over a period of about five to 10 minutes are required to initially set the clock.

Once synchronized, the client updates the clock about once every 10 minutes, usually requiring only a single message exchange. In addition to client-server synchronization. This transaction occurs via the User Datagram Protocol on port 123. NTP also supports broadcast synchronization of peer computer clocks.

Features of NTP

NTP servers, of which there are thousands around the world, have access to highly precise atomic clocks and GPS clocks. Specialized receivers are required to directly communicate with the NTP servers for these services. It is not practical or cost-effective to equip every computer with one of these receivers. Instead, computers designated as primary time servers are outfitted with the receivers, and they use protocols such as NTP to synchronize the clock times of networked computers.

NTP uses Coordinated Universal Time (UTC) to synchronize computer clock times with extreme precision, offering greater accuracy on smaller networks — down to a single millisecond in a local area network and within tens of milliseconds over the internet. NTP does not account for time zones, instead relying on the host to perform such computations.

Our Sample Scenario :

Server name –dlp.server.world

Server ip address – 192.168.0.100

Client name – http://www.server.world

Client IP address – 192.168.0.101

Required Package –  NTP

Configure NTP server (NTPd) : The Network Time Protocol daemon (ntpd) is an operating system program that maintains the system time in synchronization with time servers using the Network Time Protocol (NTP).

Step 1 : Install the NTP package using the below command

# yum install ntp

1.png

Step 2 : Now open the ntp configuration file and edit and go to line 18 and add

# vi /etc/ntp.conf

1.png

Restrict    192.168.0.0   mask    255.255.255.0    nomodify    nnotrap

1.png

Step 3 : Now go to line number 27 , comment the line 23,24,25,26 and add the below lines

server  ntp1.jst.mfeed.ad.jp  iburst

server  ntp2.jst.mfeed.ad.jp  iburst

server  ntp3.jst.mfeed.ad.jp  iburst

1.png

Step 4 : Start the NTP services and enable the service at the boot time

#systemctl start ntp

#systemtl  enable  ntp

1.png

#ntpq –p

1.png

Configure NTP server Chrony : chrony is a versatile implementation of the Network Time Protocol (NTP). It can synchronise the system clock with NTP servers, reference clocks (e.g. GPS receiver), and manual input using wristwatch and keyboard.

Step 1 : Install the chrony packages

# yum   -y install chrony

1.png

Step 2 : Now open the configuration file and go to line number 3 and comment the line 3,4,5,6 and add the below lines

# vi /etc/chrony.conf

1.png

Server   ntp1.jst.mfeed.ad.jp   iburst

Server   ntp2.jst.mfeed.ad.jp   iburst

Server   ntp3.jst.mfeed.ad.jp   iburst

1.png

Now go to line number 25 and add

Allow  192.168.0.0/24

1.png

Step 3 : Start the chrony service and enable it on boot time

# systemctl start chronyd

#systemctl enable chronyd

#systemctl restart chronyd

1

# chronyc   sources

1.png

Configure NTP client : The settings of NTP Client on CentOS are mostly the same with Server’s settings, so refer to NTPd Settings or Chrony Settings. For different settings from Server’s one, Clients don’t need to receive time synchronization requests from other computers, so it does not need to set access permission. If you don’t use NTP service daemon but use a command to sync time at once, use ntpdate like follows.

Step 1 : Install the required package using the below command

# yum   -y install ntpdate

1.png

Step 2 : Run the command for the first time of synchronization

#ntpdate  ntp1.jst.mfeed.ad.jp

1.png

Step 3 : Now enable the service for boot time

1.png

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NTP server configured Successfully!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.