Share your love
Enable NTP Service on Ubuntu 24.04 – Best Guide
As you may know, NTP is a system that syncs clock time through a network. This guide from the Orcacore team will teach you to Enable NTP Service on Ubuntu 24.04. You will learn to configure both the NTP Server and the NTP Client on Ubuntu 24.04. NTP server provides time, and an NTP client receives and synchronizes time from the server, ensuring that all systems across a network maintain accurate time.
Now follow the steps below to start installing and using the NTP protocol on Ubuntu 24.04.
Table of Contents
Steps To Enable NTP Service on Ubuntu 24.04 – Configure NTP Server and Client
To enable NTP service on Ubuntu 24.04, you must have access to your server as a non-root user with sudo privileges. To create a sudo user, you can check this guide on Create a Sudo User on Ubuntu 24.04 From Terminal.
First, we start with installing and configuring the NTP server on Ubuntu 24.04, then, we configure the NTP client.
Step 1 – Install And Configure NTP Server on Ubuntu 24.04
To enable NTP service on Ubuntu 24.04, we start by installing the NTP server. First, you must run the system update by using the following command:
sudo apt update
Then, you can install the NTP server on Ubuntu 24.04 with the following command:
sudo apt install ntp -y
Fix NTP Error – Conflict with systemd-timesyncd
Note: If you encounter the following error during the installation of NTP:
Error
The following packages have unmet dependencies:
ntpsec : Conflicts: time-daemon systemd-timesyncd : Conflicts: time-daemon
You can fix this issue, by reinstalling the systemd-timesyncd package:
Resolve Error with:
sudo apt reinstall systemd-timesyncd -y
This will fix the issue and allow you to install the NTP server. Once your installation is completed, verify your NTP is installed by checking its version:
ntpd --version
In your output, you should see something similar to this:
Output
ntpd ntpsec-1.2.2
Checking the NTP Server Status on Ubuntu 24.04
Now that you have installed the NTP server correctly, you must restart the NTP service with the following command:
sudo systemctl restart ntp
Next, you can check your NTP server status that is up and running on Ubuntu 24.04 with the following command:
sudo systemctl status ntp
In your output, you should see:
Now that your NTP server is up and running, it’s time to configure iptables for the NTP server.
Configuring iptables Rules for NTP Server on Ubuntu 24.04
At this point, you need to configure the firewall on the NTP server so that clients can access it. If you don’t have iptables installed on your Ubuntu 24.04, you can use the command below:
sudo apt install iptables -y
You must know that NTP uses 123/UDP ports. To allow the firewall rules, you need to run the following commands:
# sudo iptables -A OUTPUT -p udp --dport 123 -j ACCEPT
# sudo iptables -A INPUT -p udp --sport 123 -j ACCEPT
Once you are done, log in to your client system and follow the steps below to configure the NTP client. In this guide, our client machine is also Ubuntu 24.04.
Step 2 – Install and Configure NTP Client on Ubuntu 24.04
To enable NTP service on Ubuntu 24.04, it’s time to configure the NTP client to be time-synced with the NTP server. So you have to install the ntpd service on the client machine with the following command:
sudo apt install ntpdate -y
Then, install the NTP on your client machine by using the following command:
sudo apt install ntp -y
Once your installation is finished, it’s time to configure and sync the NTP Client with the NTP Server on Ubuntu 24.04.
Configure NTP Client on Ubuntu 24.04 – Sync NTP Client with NTP Server
At this point, you need to open the NTP Client configuration file with your favorite text editor, like Vi editor or Nano Editor:
sudo vi /etc/ntp.conf
You need to comment on the pool lines and add the “server server-ip-address prefer iburst” to the file as shown below:
...
#pool 0.debian.pool.ntp.org iburst
#pool 1.debian.pool.ntp.org iburst
#pool 2.debian.pool.ntp.org iburst
#pool 3.debian.pool.ntp.org iburst
server put-your-server-ip-address-here prefer iburst
...
Once you are finished, save and close your config file. Then, restart your NTP client service with the following command:
sudo systemctl restart ntp
Verify NTP Client is Synced with NTP Server on Ubuntu 24.04
At this point, you can check the status that its clock synced with the NTP server on Ubuntu 24.04 by using the command below:
ntpq -p
In your output, you should see something similar to this:
Output
remote refid st t when poll reach delay offset jitter
==============================================================================
server-ip-address ...
That’s it, your NTP server and client are synced together.
Conclusion
As you saw, you can easily Enable NTP Service on Ubuntu 24.04. The steps are easy and you can configure your both NTP server and client. NTP ensures that your system maintains accurate and synchronized time. By enabling NTP, you prevent time drift and ensure that your server or device operates in sync with other systems across the network. Hope you enjoy it. Also, you may like to read the following articles:
Configure NTP Server and Client on Debian 12
Disable NTP Network Time Synchronization on Ubuntu
Set up NTP Server and Client on Rocky Linux 8
FAQs
What is the purpose of enabling NTP on Ubuntu 24.04?
It ensures that your system’s clock remains accurate and synchronized with a reliable time source.
How can I verify if the NTP service is running on Ubuntu 24.04?
You can verify the NTP service by running the following command:ntpq -p
This command will display a list of NTP servers your system is syncing with, along with their status and synchronization details.
What is the difference between NTP and Chrony?
NTP and Chrony are both time synchronization services. Chrony is considered faster and more reliable for systems that are frequently offline or for virtual machines. But for systems with stable, continuous internet connections, NTP is a better choice.