Best Way to Install NTP Server and Client on Ubuntu 22.04

In this guide from the Linux Tutorials, we want to teach you to Install NTP Server and Client on Ubuntu 22.04.

The Network Time Protocol (NTP) is an application layer protocol in the TCP/IP protocol suite. It is used to synchronize the clock between the client and the server to provide high-precision time correction.

The NTP server receives accurate Coordinated Universal Time (UTC) from an authoritative clock source, such as an atomic clock or GPS. Then, the NTP client requests and receives time from the NTP server.
NTP relies on User Datagram Protocol (UDP) port 123.

Install NTP Server and Client on Ubuntu 22.04

To install and configure NTP, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Ubuntu 22.04.

Now follow the steps below to Install NTP Server and Client on Ubuntu 22.04.

Installing NTP Server on Ubuntu 22.04

First, you need to update your local package index with the command below:

sudo apt update

Then, use the command below to install the NTP server on Ubuntu 22.04:

sudo apt install ntp

Verify your NTP installation by checking its version:

sntp --version
sntp 4.2.8p12@1.3728-o (1)

Here you need to restart the NTP server with the following command:

sudo systemctl restart ntp

Verify that the NTP server is active and running on Ubuntu 22.04:

sudo systemctl status ntp
ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: e>
Active: active (running) since Mon 2022-05-30 08:25:26 CEST; 5s ago
Docs: man:ntpd(8)
Process: 50261 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, sta>
Main PID: 50280 (ntpd)
Tasks: 2 (limit: 2282)
Memory: 1.3M
CGroup: /system.slice/ntp.service
└─50280 /usr/sbin/ntpd -p /var/run/ -g -u 112:119

Configure Firewall For NTP Server

At this point, you need to configure the firewall on the NTP server so that clients can access it. To do this, run the following commands:

sudo iptables -A OUTPUT -p udp --dport 123 -j ACCEPT

sudo iptables -A INPUT -p udp --sport 123 -j ACCEPT

For more information about Iptables, you can visit this guide on How To Install Iptables on Ubuntu 22.04.

NTP Client on Ubuntu 22.04

Here you need to configure the NTP client to be time-synced with the NTP server. To do this, you have to install the ntpd service on the client machine with the following command, here our client machine is Ubuntu:

sudo apt install ntpdate

Then, install the NTP on your client machine:

sudo apt install ntp

After your installation is finished, let’s configure the NTP client.

NTP Client Configuration

It is now time to configure the NTP client so that its clock can be synced with the NTP server.

You need to open the NTP configuration file with your favorite text editor, here we use vi:

sudo vi /etc/ntp.conf

You need to comment on the pool lines and add the “server server-ip-address prefer iburst” to the file as shown below:

#pool iburst
#pool iburst
#pool iburst
#pool iburst
server server-ip-address prefer iburst

When you are finished, save and close the file.

Now you need to restart the NPT client to apply the changes:

systemctl restart ntp

Then, you can check the status that its clock synced with the NTP server on Ubuntu 22.04:

ntpq -p
remote         refid  st t  when poll reach delay offset jitter
server-ip-address     ...

For more information, you can visit the official NTP documentation.


With this guide, you learn to Install NTP Server and Client on Ubuntu 22.04. I hope you enjoy it.

Also, you may be interested in these articles:

Configure NTP Server and Client on Debian 12 Bookworm

Set Up Time Synchronization on Ubuntu 22.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!