NTP stands for Network Time Protocol. It is a protocol or service used to synchronize the clock of your client computers with the clock of a server. The server's clock is also synchronized with the Internet.
In this article, I'll show you how to set up an NTP server in your environment and synchronize the clock with the client machines. I have run all the commands and procedures on my Debian 11 machines.
before we start installing new packages, we should take care that the Debian repository lists are updated. Open up the terminal with root privileges and run the following command to update the package repository.
apt-get update
To install an NTP server, run the following command on the terminal. When you are prompted, enter Y from the keyboard.
apt-get install ntp
Wait for the installation to finish. This may take several minutes to complete depending on your Internet speed.
Below is the sample output.
You can verify the installation and version by executing the below command.
sntp --version
Run the following command to restart the NTP server.
systemctl restart ntp
To verify whether the NTP service is actually running, execute the following command.
systemctl status ntp
Below is the sample output which shows that the NTP service is running on the server.
Open up the 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 the sample output.
Let us configure the NTP client to be time synced with the NTP server. For this, you have to install the ntpd daemon on the client machine.
apt-get install ntpdate
Wait for the installation to finish. This could take several minutes to complete depending on your internet speed.
Below is the sample output.
Open up the terminal with root privileges and run the following command.
apt-get install ntp
Wait for the installation to finish. This may take several minutes to complete depending on the internet speed.
Below is the sample output.
Once you have installed the NTP daemon on the client machine, it is now time to configure it so that its clock can be synced with the NTP server.
Run the following command to open a configuration file in the nano editor.
nano /etc/ntp.conf
Add the following lines,
server 10.1.1.1 prefer iburst
Below is the sample output after adding the above line to the configuration file.
Restart the NTP service after adding the above line by running the following command on the terminal with root privileges.
systemctl restart ntp
To check the status, run the following command on the terminal.
ntpq -p
Below is the sample output.
We are done with the basic configuring of an NTP server and client. Good luck!
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…