Skip to content
Follow
Ubuntu Linux

How to Set Up NTP Server and Client on Ubuntu 24.04

Richard
Written by
Richard
Mar 9, 2025 Updated Oct 10, 2026 7 min read
How to Set Up NTP Server and Client on Ubuntu 24.04
How to Set Up NTP Server and Client on Ubuntu 24.04

Chrony keeps your computer clocks in sync on Ubuntu 24.04 by setting up a Network Time Protocol (NTP) server and client. NTP makes sure all computers on a network share the exact same time, so event logs stay correct and security tools run properly.

Advertisement

Accurate time stops errors caused by clock drift between machines. Clock drift is what makes log entries from two servers impossible to line up, and it breaks anything that depends on timestamps, such as Kerberos tickets and TLS certificate checks. You need root access (or a user that can run sudo) to install and configure these time-sync tools. The steps work on a fresh Ubuntu 24.04 install, and the server needs a working internet connection to reach its upstream time sources.

⚡ Quick Answer

Install the Chrony package using `sudo apt install chrony`. Configure `/etc/chrony/chrony.conf` to specify your desired NTP servers and allow network access. Then, set up clients by editing `/etc/systemd/timesyncd.conf` to point to your NTP server.

Advertisement

Install NTP server

Installing an NTP server on Ubuntu 24.04 means choosing between NTPsec and Chrony to keep your system clock accurate. You only need one of these programs, so install one and skip the other. To get NTPsec, run the command sudo apt install ntpsec in your terminal. Make sure you are logged in as a user with sudo rights, or the install will fail with a permission error.

You can pick one of the two to use in your environment. NTPsec is a security-hardened fork of the classic NTP daemon, so it suits people who want that familiar behavior. Chrony is lighter and recovers quickly after a network drop or a suspend, which makes it a good fit for laptops, virtual machines and most general servers.

Do not run both on the same machine. They both listen on UDP port 123 and will get in each other’s way. Installing either one also takes over the time-sync job from the default Ubuntu time service, so you do not need to disable anything by hand first.

Install NTPsec

Advertisement
  1. Open a terminal and run the command below to install NTPsec. Enter your password if prompted, and answer Y if apt asks you to confirm.
🐧Bash / Shell
sudo apt install ntpsec

When apt finishes without errors, the install is done. After installing NTPsec, you can find its configuration file at the following location: [/etc/ntpsec/ntp.conf]. Open it with root rights, because a normal user can read the file but cannot save changes to it.

Install Chrony

  1. To install Chrony instead, run the command below. Skip this step if you already installed NTPsec.
🐧Bash / Shell
sudo apt install chrony

Once apt returns to the prompt, Chrony is installed. After installing Chrony, you can find its configuration file at the following location: [/etc/chrony/chrony.conf]. As with NTPsec, you need root rights to edit it.

Configure NTP server

Configuring your NTP server on Ubuntu 24.04 means editing the main settings file so your system points to reliable time sources. You open the configuration file, turn off the default time pools by adding hash symbols, and add the time servers you prefer. Follow the section for the program you installed.

Advertisement

NTPsec configuration

  1. Open the NTPsec configuration file in a text editor with root rights.
  2. Comment out the bold lines by putting a # at the start of each one. This disables the default Ubuntu NTP pool.
  3. Add the pool you want to use, as shown in the block below. Pick a pool close to your location, because a nearby source gives a more accurate and stable clock.
💻Code
# Comment this out if you have a refclock and want it to be able to discipline
# the clock by itself (e.g. if the system is not connected to the network).
#tos minclock 4 minsane 3

# Specify one or more NTP servers.

# Public NTP servers supporting Network Time Security:
# server time.cloudflare.com nts

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See https://www.pool.ntp.org/join.html for
# more information.
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst


pool time.nist.gov iburst

# Use Ubuntu's ntp server as a fallback.
#server ntp.ubuntu.com
  1. Save and exit the file. In nano, press Ctrl+O, then Enter, then Ctrl+X.
  1. Check the status with the command below. If the service was already running while you edited the file, restart it first so it reads the new settings.
💻Code
ntpq -p

Chrony configuration

  1. Open the Chrony configuration file in a text editor with root rights.
  2. Comment out the bold lines by putting a # at the start of each one. This disables the default Ubuntu NTP pool.
  3. Add the pool you want to use, as shown in the block below. Again, choose one near you.

The server must also be willing to answer other machines. If your clients cannot sync later, check that the Chrony configuration allows requests from your network and that UDP port 123 is open in any firewall between the server and the clients.

💻Code
# About using servers from the NTP Pool Project in general see (LP: #104525).# Approved by Ubuntu Technical Board on 2011-02-08.# See http://www.pool.ntp.org/join.html for more information.#pool ntp.ubuntu.com        iburst maxsources 4#pool 0.ubuntu.pool.ntp.org iburst maxsources 1#pool 1.ubuntu.pool.ntp.org iburst maxsources 1#pool 2.ubuntu.pool.ntp.org iburst maxsources 2pool time.nist.gov iburst# add this line to allow all clients on network allow 192.168.156.0/24
  1. Save the file and exit. In nano, press Ctrl+O, then Enter, then Ctrl+X.
  1. Restart Chrony with the command below. Chrony only reads its configuration file at startup, so this restart is required for your changes to take effect.
🐧Bash / Shell
sudo systemctl restart chrony
  1. Check the status with the command below. You should see the service as active and running. If it shows as failed, re-open the configuration file and look for a typo in the lines you changed.
💻Code
chronyc sources

Set up NTP client

Setting up an NTP client on Ubuntu 24.04 does not require extra software, because the tools are already built into the operating system. You only edit the system time configuration file to point the computer at your local NTP server, and it then synchronizes its clock automatically. Run these steps on each machine that should take its time from your server.

Advertisement

There is no additional software to install on the client. Do not install NTPsec or Chrony on it unless you want that machine to act as a server too.

  1. Run the command below to open the NTP client configuration file.
🐧Bash / Shell
sudo nano /etc/systemd/timesyncd.conf
  1. Add the local server name in the file, as shown in the block below. Use the host name or IP address of the machine where you set up NTPsec or Chrony. If you use a host name, make sure the client can resolve it.
💻Code
[Time]
NTP=srv1.example.com
  1. Save the file and exit. In nano, press Ctrl+O, then Enter, then Ctrl+X.
  1. Restart the services with the command below, so the client picks up the new server.
🐧Bash / Shell
sudo systemctl restart systemd-timesyncd
  1. Check the status with the command below.
💻Code
timedatectl timesync-status

You should see output similar to the one below. Look for your local server named as the time source and for a line showing that the system clock is synchronized. The first sync can take a short while after the restart, so wait a minute and run the status check again before you start troubleshooting. If it still does not sync, confirm that the server is reachable from the client and that UDP port 123 is not blocked.

💻Code
       Server: 192.168.156.130 (srv1.example.com)
Poll interval: 1min 4s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 2
Reference: 84A36006
Precision: 1us (-26)
Root distance: 16.433ms (max: 5s)
Offset: +2.247ms
Delay: 380us
Jitter: 0
Packet count: 1
Frequency: +31.702ppm

That should do it!

Conclusion:

Advertisement

Setting up an NTP server and client on Ubuntu 24.04 ensures that your devices maintain accurate time synchronization, which is vital for various network operations. Here are the key points to remember:

  • NTP Importance: Essential for keeping accurate, synchronized time across devices.
  • Server Options: Choose between NTPsec and Chrony based on your needs, and install only one of them.
  • Configuration: Adjust the configuration files to specify desired NTP servers and settings, then restart the service so the changes apply.
  • Client Setup: No additional software is required; simple configuration is sufficient.
  • Verification: Use commands to check the status and ensure synchronization works correctly.
  • Benefits of Accuracy: Consistent timestamps contribute to better security protocols, logging, and data integrity.

Following the outlined steps, you can establish a reliable NTP setup to improve your network's time management.

Have a question about this guide?

Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.

Did this guide fix your problem?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *