How to set up NTP server and client on Debian 10

NTP stands for Network Time Protocol. It is a protocol or service that is used to synchronize the clocks of your client machines with those of the server. The server clock is additionally synchronized with the Internet.

In this article, I’m going to show you how you can set up an NTP server in your environment and synchronize the clocks with client computers. I have followed all the commands and procedures on my Debian 10 machines.

Updating the Debian Package Repository

Open a terminal as root and run the following command to update the package repository.

apt-get update

Below is an example of the output.

Install NTP Server on Debian

To install the NTP server, run the following command in a terminal. When prompted, enter Y using the keyboard.

apt-get install ntp

Wait for the installation to complete. This may take several minutes depending on your internet speed.

Below is an example of the output.

Install NTP server package using apt

Checking the installation

You can check the installation and version by running the following command.

sntp --version

How to set up NTP server and client on Debian 10

Reboot NTP Server

Run the following command to restart the NTP server.

systemctl restart ntp

To check if the NTP service is actually running, run the following command.

systemctl status ntp

Below is a sample output that shows the NTP service is running on the server.

How to set up NTP server and client on Debian 10

Configure a firewall on the NTP server so clients can access it

Open a terminal on the NTP server and run the following command with root privileges.

iptables -A OUTPUT -p udp --dport 123 -j ACCEPT
iptables -A INPUT -p udp --sport 123 -j ACCEPT

Below is an example of the output.

Firewall configuration

Installing the NTP client

Let’s configure the NTP client to synchronize time with the NTP server. To do this, you need to install the ntpd daemon on the client computer.

apt-get install ntpdate

Wait for the installation to complete. This may take several minutes depending on your internet speed.

Below is an example of the output.

Installing ntpdate

Installing NTP on the client

Open a terminal with superuser rights and run the following command.

apt-get install ntp

Wait for the installation to complete. This may take a few minutes, depending on your internet speed.

Below is an example of the output.

Install ntp package

NTP client setup

After you have installed the NTP daemon on the client computer, it is time to configure it so that its clock can synchronize with the NTP server.

Run the following command to open the config file in nano editor.

nano /etc/ntp.conf

Add the following lines,

server 10.1.1.1 prefer iburst

Below is an example of the output after adding the above line to the config file.

Configure ntp client

Restart the NTP service after adding the above line by running the following command on a terminal with root privileges.

systemctl restart ntp

Restart NTP

To check the status, run the following command on the terminal.

ntpq -p

Below is an example of the output.

ntpq

Output

We are done with the basic setup of the NTP server and client. Good luck!

How to set up NTP server and client on Debian 10

Sidebar