How to Add Ntp Server in Linux
If you want to know how to add ntp server in linux, the usual process is to edit the time synchronization configuration for the service your system uses, then restart that service and verify the new server is active. Most modern Linux distributions use chrony or systemd-timesyncd, while some older systems still use ntpd.
What it means to add an NTP server
Adding an NTP server in Linux means telling your system which time source to use for clock synchronization. That source can be a public server, such as a pool server, or a private internal server used by your organization.
This matters because accurate time affects log files, scheduled jobs, authentication, certificates, backups, and distributed systems. If the time is wrong, troubleshooting becomes harder and some services may fail.
Check which time service your Linux system uses
Before editing any configuration, identify the active time-sync service. Different Linux distributions use different tools, and the steps are slightly different for each one.
Check for chrony
systemctl status chronyd
On some systems the service name is chrony instead of chronyd. If one name does not work, try the other.
Check for ntpd
systemctl status ntpd
Check for systemd-timesyncd
timedatectl status
This command shows whether system time synchronization is active and often indicates which service is handling it.
Add an NTP server in chrony
chrony is the preferred option on many modern Linux systems because it works well on laptops, virtual machines, and systems that do not stay online all the time.
1. Open the chrony configuration file
The file is usually:
/etc/chrony.conf
On some distributions, it may be:
/etc/chrony/chrony.conf
2. Add your NTP server
Look for existing server or pool lines and add your own server. For example:
server time.example.com iburst
You can also use an IP address:
server 192.168.1.20 iburst
The iburst option helps chrony synchronize faster when it first starts.
3. Save the file and restart chrony
sudo systemctl restart chronyd
If your service is named differently, use:
sudo systemctl restart chrony
4. Enable chrony at boot if needed
sudo systemctl enable chronyd
Add an NTP server in ntpd
ntpd is the older traditional NTP daemon. Some systems still use it, especially older servers or installations that have not moved to chrony.
1. Open the ntpd configuration file
The standard file is:
/etc/ntp.conf
2. Add your NTP server
Add a server line such as:
server time.example.com iburstYou can keep existing servers if you want multiple time sources, which is often a good idea. NTP is usually more reliable when it can compare more than one source.
3. Restart ntpd
sudo systemctl restart ntpd
4. Enable it at boot if needed
sudo systemctl enable ntpd
Add an NTP server with systemd-timesyncd
Some desktops and lightweight systems use systemd-timesyncd. It is simpler than chrony or ntpd, but it is also more limited.
1. Edit the timesyncd configuration
The main file is usually:
/etc/systemd/timesyncd.conf
Find the NTP= line and set your server:
NTP=time.example.com 192.168.1.20You can list more than one server, separated by spaces.
2. Restart the service
sudo systemctl restart systemd-timesyncd3. Check that it is enabled
systemctl status systemd-timesyncdReload the time sync service
After making changes, restart the relevant service so Linux reads the updated configuration. In most cases, a full restart is safer than a reload because it ensures the new server is applied immediately.
Common restart commands:
sudo systemctl restart chronyd
sudo systemctl restart ntpd
sudo systemctl restart systemd-timesyncd
Verify the server is in use
Do not stop after editing the config. Always check that the system is actually using the new NTP server.
Verify chrony
chronyc sources -vThis shows your configured time sources and marks which one chrony is using.
You can also check tracking information:
chronyc trackingVerify ntpd
ntpq -pThis displays the peers ntpd is using and whether they are reachable and synchronized.
Verify systemd-timesyncd
timedatectl timesync-statusOn some distributions, this command provides the current synchronization source and status.
Check general sync state
timedatectl statusLook for whether network time synchronization is active and whether the system clock is synchronized.
Common problems and fixes
If the new server does not work, the issue is usually one of a few common problems.
- Wrong service edited: Make sure you changed the config file for the service your system actually uses. Editing
ntp.confwill not help if the machine is running chrony. - Configuration syntax error: A missing space or incorrect directive can stop the service from reading the file. Check the service logs with
journalctl -ufor details. - DNS resolution failure: If you used a hostname, confirm the system can resolve it. Try using the server IP address temporarily to test.
- Firewall or network blocking: NTP uses UDP port 123. If that port is blocked between the client and server, synchronization will fail.
- Server not reachable: Confirm the NTP server is online and responding to requests from your network.
- Old cached state: Sometimes the service needs a restart before it picks up the new source cleanly.
When to use a custom NTP server
A custom NTP server is useful when you need time from a local internal source rather than the public internet. Common examples include:
- Servers inside a restricted network
- Virtualized environments
- Isolated or air-gapped systems
- Organizations that want all machines to sync to the same internal time source
If you do not need a private server, public NTP pool servers are often easier to use. For most standard systems, one reliable public source and one backup source are enough.
Best practice for adding NTP servers
When configuring time sync on Linux, a few habits make the setup more reliable:
- Use at least two time sources when possible.
- Prefer chrony on modern Linux servers unless you have a reason to use ntpd.
- Use hostnames only if DNS is stable and reliable.
- Verify synchronization after every change.
- Keep firewall rules consistent if you manage both the client and the server.
Quick example for most Linux systems
If you are using chrony, a typical setup looks like this:
server time.example.com iburstThen restart the service and verify it:
sudo systemctl restart chronyd
chronyc sources -v
If that server appears as reachable and selected, your Linux system is using it successfully.
Frequently Asked Questions About how to add ntp server in linux
How do I add an NTP server in Linux?
Edit the config file for your time service, add the NTP server line, restart the service, then verify the new source is active.
Which file do I edit to add an NTP server?
It depends on the service. Use /etc/chrony.conf or /etc/chrony/chrony.conf for chrony, /etc/ntp.conf for ntpd, and /etc/systemd/timesyncd.conf for systemd-timesyncd.
How do I restart NTP after changing the server?
Use systemctl restart chronyd, systemctl restart ntpd, or systemctl restart systemd-timesyncd, depending on the service in use.
How can I check if my Linux system is syncing to the new server?
Use chronyc sources -v for chrony, ntpq -p for ntpd, or timedatectl timesync-status for systemd-timesyncd.
Should I use chrony or ntpd on Linux?
For most modern Linux systems, chrony is the better choice. It is widely supported, handles network changes well, and is the default on many distributions.
Why is my NTP server not working after I add it?
The most common reasons are a config typo, DNS resolution problems, a blocked UDP port 123, or editing the wrong service file.
Conclusion
To add an NTP server in Linux, first identify whether your system uses chrony, ntpd, or systemd-timesyncd. Then edit the correct configuration file, add the server, restart the service, and verify synchronization with the appropriate status command. If the server does not appear, check for syntax errors, DNS issues, and blocked network traffic on UDP port 123.
