Skip to content

How To Setup NTP Server on Ubuntu & LinuxMint

How to SetUp Time Synchronization (NTP) Server on Ubuntu & LinuxMint Operating systems. How To Setup NTP Server on Ubuntu, Debian and LinuxMint.

Steps
6
Category
Linux
Covers
Linux Mint, Ubuntu
On this page 6 steps

Network Time Protocol (NTP) is a protocol used to synchronize computer clock times in a network of computers. NTP uses Coordinated Universal Time (UTC) to synchronize computer clock times to a millisecond, and sometimes to a fraction of a millisecond. Setting up an NTP Server on Ubuntu & Linux Mint involves a series of steps which are detailed below.

Pre-requisites:

Before we begin, please ensure you have the following:

  • A machine running Ubuntu or Linux Mint.
  • Sudo or root access to run privileged commands.
  • A stable internet connection.

Step 1 of 6Update Your System

First, update your system to the latest package versions. This helps to ensure that you have the latest security patches and system updates. Open Terminal and execute the following commands:

sudo apt-get update 
sudo apt-get upgrade 

Step 2 of 6Install NTP

The next step is to install the NTP package which is available in the default Ubuntu & Linux Mint repositories. Run the following command to install NTP:

sudo apt-get install ntp 

Step 3 of 6Configure NTP Server

Once installed, you need to configure the NTP server. The configuration file for NTP is located at /etc/ntp.conf. Use your favorite text editor to edit this file. For example, to use nano, type:

sudo nano /etc/ntp.conf 

In this configuration file, you can specify the NTP servers to which your machine will synchronize. These servers are specified in lines that begin with “server”. For example:

The iburst option allows the system to send a burst of packets if the server is unreachable.

Save your changes and close the editor.

Step 4 of 6Allow NTP Through the Firewall

If you have a firewall enabled, you need to allow NTP through it. NTP uses UDP port 123, so you will need to allow this port through the firewall. If you’re using ufw firewall, you can do this with the following command:

sudo ufw allow 123/udp 

Step 5 of 6Restart NTP Service

After making the changes, restart the NTP service for the changes to take effect. Use the following command to restart the NTP service:

sudo systemctl restart ntp 

Step 6 of 6Verify NTP is Working

Finally, you should verify that NTP is working correctly. You can do this by querying the NTP service status and peers.

To check the status of the NTP service, use:

sudo systemctl status ntp 

To check the synchronization status, use:

ntpq -p 

This will display a list of configured NTP peers, along with information about the synchronization with each. Look for a * symbol next to one of the peers. This indicates that your NTP server is synchronizing with that peer.

Congratulations, you’ve set up an NTP server on your Ubuntu or Linux Mint machine!

Conclusion

Setting up an NTP server is a crucial task for maintaining correct time across all machines in a network. By following this guide, you now have a better understanding of how to install, configure, and verify the NTP server in Ubuntu & Linux Mint.

Bear in mind, managing an NTP server involves regular monitoring to ensure accurate synchronization of time. You should also keep your system and NTP software updated for best security and performance.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

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


Back to top