How to Set Up NTP Server and Client on Ubuntu 24.04
Setting up an NTP server and client on Ubuntu 24.04 uses the Chrony package to keep computer clocks in sync.
Network Time Protocol, or NTP, is a system that makes sure all computers on a network have the exact same time. Chrony is the standard and best choice for this job on Ubuntu 24.04, and it’s known for being quick and precise.
Having accurate, matching times on all your devices is important for many things. It helps with keeping good logs of computer events, makes sure security systems work correctly, and allows different systems to work together smoothly. Getting your Ubuntu 24.04 system’s time right stops issues caused by time differences.
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.
Install NTP server
You can set up an NTP server on Ubuntu 24.04 by installing either NTPsec or Chrony. Both programs help keep your computer’s clock accurate. You only need to choose and install one of them to get started.
You can pick one of the two to use in your environment.
Install NTPsec
Run the command below to install NTPsec.
sudo apt install ntpsec
After installing NTPsec, you can find its configuration file at the following location: [/etc/ntpsec/ntp.conf].
Install Chrony
To install Chrony, run the command below.
sudo apt install chrony
After installing Chrony, you can find its configuration file at the following location: [/etc/chrony/chrony.conf].
Configure NTP server
Once you’ve installed your NTP server software on Ubuntu 24.04, you need to configure it to use specific time sources. This involves editing the main settings file to tell your server where to get accurate time information from.
NTPsec configuration
# 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
Save and exit the file.
Check the status.
ntpq -p
Chrony configuration
# 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
#pool 1.ubuntu.pool.ntp.org iburst maxsources 1
#pool 2.ubuntu.pool.ntp.org iburst maxsources 2
pool time.nist.gov iburst
# add this line to allow all clients on network
allow 192.168.156.0/24
Save the file and exit.
Restart Chrony
sudo systemctl restart chrony
Check status.
chronyc sources
Set up NTP client
Setting up your Ubuntu 24.04 computer as an NTP client is straightforward and doesn’t need extra software. You simply adjust the current time settings to connect to your NTP server, ensuring your computer stays synchronized with accurate time.
There’s no additional software to install on the client.
Run the command below to open the NTP client configuration file.
sudo nano /etc/systemd/timesyncd.conf
Then, add the local server name in the file.
[Time]
NTP=srv1.example.com
Save the file and exit.
Restart the services.
sudo systemctl restart systemd-timesyncd
Check status.
timedatectl timesync-status
You should see output similar to the one below.
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:
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.
- Configuration: Adjust the configuration files to specify desired NTP servers and settings.
- 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 successfully establish a reliable NTP setup to enhance your network’s time management.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!