The Network Time Protocol (NTP) is a protocol that is used to synchronize the time on your server with a reference time source. In this article, we will guide you through the process of installing an NTP server on Ubuntu 18.04.
Before we begin, make sure that you have a fresh installation of Ubuntu 18.04 and that the necessary dependencies are installed on your system. You will also need to be logged in as a user with sudo
privileges.
Install the NTP package
The first step is to install the NTP package from the default Ubuntu repositories. To do this, run the following command in the terminal:
sudo apt update
sudo apt install ntp
This will install the NTP package on your system.
Configure the NTP server
After installing the NTP package, we need to configure the NTP server. To do this, open the NTP configuration file using the following command:
sudo nano /etc/ntp.conf
In the configuration file, you can specify the NTP servers that the NTP daemon will use to synchronize the time. By default, the NTP daemon uses the public NTP servers provided by pool.ntp.org
.
You can also specify the timezone for your server by adding the following line to the configuration file:
server localtime true
Save the file and exit the editor.
Restart the NTP daemon
After configuring the NTP server, we need to restart the NTP daemon to apply the changes. To do this, run the following command in the terminal:
sudo systemctl restart ntp
This will restart the NTP daemon and apply the changes that you made to the configuration file.
Verify the NTP synchronization
After restarting the NTP daemon, you can verify that it is synchronizing the time correctly using the following command:
ntpq -p
This will display the list of NTP servers that the NTP daemon is using to synchronize the time, along with the status of the synchronization.
By following these steps, you should have successfully installed and configured an NTP server on your Ubuntu 18.04 system. You can now use the NTP server to synchronize the time on your server with a reference time source.