UbuntuUbuntu Based

How To Install NTP on Ubuntu 22.04 LTS

Install NTP on Ubuntu 22.04

In this tutorial, we will show you how to install NTP on Ubuntu 22.04 LTS. For those of you who didn’t know, NTP (Network Time Protocol) is a protocol designed to synchronize the clocks of computer systems over networks. It operates on a hierarchical system of time servers, where each level references the next higher level to obtain accurate time information. At the top of this hierarchy are highly precise time sources, such as atomic clocks or GPS receivers, which serve as the ultimate reference for time synchronization.

NTP uses the Coordinated Universal Time (UTC) timescale as its reference, ensuring that all systems on the network are synchronized to a common time standard. Accurate time synchronization is essential for various applications, including distributed systems, databases, security protocols (e.g., Kerberos), and log file management. Without proper time synchronization, these systems may experience issues such as inconsistent log entries, failed authentication, and incorrect timestamps, leading to potential security vulnerabilities and operational challenges.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the NTP on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for NTP.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install NTP on Ubuntu 22.04 LTS Jammy Jellyfish

Step 1. To begin, update your Ubuntu server’s package lists and install the ntp package, which contains the NTP server and client components. Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade
sudo apt install wget apt-transport-https gnupg2 software-properties-common

Step 2. Installing NTP on Ubuntu 22.04.

NTP is readily available in the Ubuntu repository. To install it, open a terminal and run the following command below:

sudo apt install ntp

Once the installation is complete, NTP will be automatically started, and it will synchronize the system clock with the default NTP server pool.

Step 3. Configuring NTP Server.

In some cases, you may want to configure your Ubuntu 22.04 system to act as an NTP server. This is particularly useful in a network environment where you have many devices that need to synchronize their time with a central server.

To configure your Ubuntu 22.04 system as an NTP server, you need to edit the NTP configuration file located at /etc/ntp.conf. Open the file using your preferred text editor:

nano /etc/ntp.conf

Install NTP on Ubuntu 22.04 LTS Jammy Jellyfish

If you’re looking to optimize the accuracy and reliability of your network time synchronization, it may be a good idea to switch to NTP server pools that are geographically closer to your location. The NTP Pool Project website is a great resource to help you find the closest NTP server pool. To demonstrate, let’s say you’re in Singapore and want to update your NTP configuration files with a list of nearby servers. You can easily replace the default NTP pool list in the configuration files with the new servers from the NTP Pool Project website.

Next, restart the NTP service for the changes to take effect:

sudo systemctl restart ntp

To verify that the NTP server is running correctly, use the following command:

sudo systemctl status ntp

Step 4. Configuring NTP Client.

If you have other devices on your network that need to synchronize their time with the Ubuntu 22.04 NTP server, you need to configure them as NTP clients.

To configure an NTP client, you need to edit the NTP configuration file located at /etc/ntp.conf. Open the file using your preferred text editor:

nano /etc/ntp.conf

Add the following line:

server (your-ntp-server-ip)

Save and close the file, then restart the NTP service for the changes to take effect:

sudo systemctl restart ntp

Step 5. Opening Firewall for NTP

To allow NTP traffic through your Ubuntu server’s firewall, you need to open UDP port 123. If you are using the ufw firewall, run the following command:

sudo ufw allow 123/udp

If you have clients on other networks that need to synchronize with your NTP server, you may need to configure additional firewall rules on your network devices to allow NTP traffic.

Step 6. Verify NTP Synchronization.

After configuring and restarting the NTP service, we can verify that the system is synchronized with the NTP server. Run the following command to check the status of the NTP service:

ntpq -p

This command will display a list of NTP servers and their synchronization status. If your system is properly synchronized, you should see an asterisk (*) next to the NTP server you added to the ntp.conf file.

Step 7. Troubleshooting NTP Issues

If you encounter issues with NTP synchronization, consider the following troubleshooting tips:

  • Ensure that the NTP server and client are reachable on the network and that firewalls are not blocking UDP port 123.
  • Verify that the NTP configuration files (/etc/ntp.conf) on both the server and client are properly configured and point to the correct NTP servers.
  • Check the NTP log files (/var/log/ntp.log) for any error messages or indications of synchronization problems.
  • Use the ntpdate command to perform a one-time synchronization and check if the clock is adjusted correctly.
  • Restart the NTP service on both the server and client using sudo systemctl restart ntp to apply any configuration changes.

If the issue persists, consult the official NTP documentation and community forums for further assistance and guidance specific to your setup.

Congratulations! You have successfully installed NTP. Thanks for using this tutorial for installing the NTP on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official NTP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button