How to Set Up NTP Server and Client on Ubuntu 24.04
You set up an NTP server and client on Ubuntu 24.04 using the Chrony package.
Network Time Protocol (NTP) synchronizes computer clocks across a network, ensuring all devices share an accurate, consistent time. Chrony is the default and recommended NTP implementation for Ubuntu 24.04, known for its speed and accuracy.
This is crucial for tasks like accurate logging, secure authentication, and coordinated system operations. Getting your time perfectly aligned on Ubuntu 24.04 prevents common problems caused by time discrepancies.
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
There are multiple NTP servers one can use on Ubuntu systems. Users can use [NTPsec] or [Chrony].
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 the NTP server is installed, open its configuration file and add the highlighted lines.
NTPsec configuration
Comment out [#] the bold lines to disable the default NTP pool. Then, add the pool you want to use.
# 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
Comment out [#] the bold lines to disable the default NTP pool. Then, add the pool you want to use.
# 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
Now that the NTP server is set up, you can configure your Ubuntu client to synchronize its time with the server.
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!