Do you know what an NTP server is? In a computer data network it is very important that there is consistency regarding the time / min / second / date that each piece of equipment has. In this sense, it is important that there is at least one centralized service that allows all machines to obtain the date / time information (thus being all synchronized with the same date / time).
Today we are going to learn how easy it is to have a time server (NTP server) in Ubuntu and derivatives and how to configure them aware.
The NTP (Network Time Protocol) is a synchronization protocol, which allows you to automatically set the machines’ clocks. This protocol uses port 123 and the UDP protocol and is designed to be robust and reliable, ensuring that a server’s internal clock is maintained at the exact time, based on synchronization information by other NTP servers in the world.
This synchronization is important, as in addition to always having the machine’s clock set, it allows, for example, to compare logs of several machines in very short periods of time and thus evaluate certain events. Having configured an NTP server, the machines can adjust the current time of the clock with precision in the order of milliseconds.
Installing the NTP server
Before we start installing the NTP server, just leave a tip. Using the timedatectl command, we can know all the system information regarding the date and time.
Installing the NTP service is very simple. To do so, just open the terminal and enter the following command:
Next we go to the configuration file (/etc/ntp.conf) and we are going to add the NTP service of the Lisbon Astronomical Observatory by adding the following addresses:
- server ntp02.oal.ul.pt
- server ntp04.oal.ul.pt
After making the changes, save and exit the editor and restart the service with the command:
sudo systemctl restart ntp
The server must allow communication to the logical port UDP 123. They can do this with the following command:
sudo ufw allow from any to any port 123 proto udp
To disable Ubuntu’s default synchronization, run the following command
Configure the hour service on the client
On the client side the process is identical. To do this, just define the server’s IP address as server (let’s assume it is 10.10.10.254). The configuration should be something like this.
As you have seen, it is very easy to configure NTP on Ubuntu and its derivatives. A system’s date / time is one of its most important settings. Through this updated information, we can, in certain cases, check through the logs everything that happened with our system at a certain date / time. If you haven’t already, here’s a good opportunity.