NTP(The Network Time Protocol)

pratham
4 min readMar 24, 2023

--

D21ce164-Pratham patel

Network Time Protocol (NTP) is an internet protocol used to synchronize with computer clock time sources in a network. It belongs to and is one of the oldest parts of the TCP/IP suite.

The Network Time Protocol is widely deployed in the Internet to synchronize computer clocks to each other and to international standards via telephone modem, radio and satellite.

Port Number for NTP is 123.

A good example of a NTP server is ntp.pool.org. This is a cluster of NTP servers that many servers and network devices use to synchronize their clocks. NTP uses a concept called “stratum” that defines how many NTP hops away a device is from an authorative time source.

Name of India’s NTP server

NIC: NIC runs the NTP service through samay1.nic.in and samay2.nic.in. NPL: The current IP addresses are 14.139. 60.103, 14.139

How to Install NTP Server and Client(s) on Ubuntu…..

Install NTP server

Step 1: install NTP server

Command:

$ sudo apt update
$ sudo apt install ntp

Step 2:Configure NTP server

command:

$ cat /etc/ntp.conf

Step 3: add the lines in your config file by using nano or your preferred text editor

command:

$ sudo nano /etc/ntp.conf

Step 4:Once you’ve made these changes, save and exit the configuration file. Restart the NTP service for the changes to take effect.

command:

$ sudo systemctl restart ntp

Step 5:Check on the status of the NTP service at any time.

command:

$ sudo systemctl status ntp

Step 6:Clients trying to connect to your NTP server will be doing so on UDP port 123. If you have the UFW firewall enabled on you system, be sure to configure it to allow these incoming connection requests.

command:

$ sudo ufw allow from any to any port 123 proto udp
Rules updated
Rules updated (v6)

NTP client configuration

Step 1:First, we need to install the ntpdate package. We can use this to verify connectivity between the client and the NTP time server we created.

command:

$ sudo apt update
$ sudo apt install ntpdate

Step 2:Next, let’s attempt to mantually sync our system time with the NTP server. Type the following command, substituting your NTP server’s IP address or hostname where appropriate

command:

$ sudo ntpdate 192.168.100.4

Step 3:That seems to be working as we’d expect. Next, be sure to disable Ubuntu’s default timesyncd service, as this will conflict with our attempts to synchronize with the NTP server.

command:

$ sudo timedatectl set-ntp off

Step 4:Now, we need to install the NTP daemon on our client system so we can configure it to pull the time from our NTP server that we set up earlier.

command:

$ sudo apt install ntp

Step 5:We only need to add a single line to our ntp.conf file, and we can do that very easily with a single command. Just make sure to replace the IP address below with either the hostname or the IP address of your NTP server.

command:

$ sudo bash -c "echo server 192.168.100.4 prefer iburst >> /etc/ntp.conf"

Step 6:Then, restart the NTP daemon

command:

$ sudo systemctl restart ntp

Step 7: use the ntpq command to list the NTP time synchronization queue

command:

$ ntpq -p

--

--