Imagine you have several Ubuntu servers running different applications.
Each server sends logs to the logger server, and you have monitoring software that collects resource metrics. Both services show logs with a timestamp. That requires all servers and devices in a network to have accurate and consistent time information.
This is where Network Time Protocol steps into the picture.
NTP stands for Network Time Protocol. The main purpose of NTP is to make sure that all computers and devices in a network have accurate and consistent time information.
Network Time Protocol is a client-server application. Each device in a network must be equipped with NTP client software to synchronize its clock to the NTP server.
Here are five important NTP use cases for DevOps:
Let’s talk about two main NTP implementation methods: NTP in the internal, closed network, and NTP in the external network with internet access.
Closed network:
It’s a network without internet access, so you will need to install an NTP server inside the network and connect our NTP clients to it.
There is an option to use the router with a calendar function as an NTP server, but in this tutorial, I will use one of the Windows computers running Windows 10 for that.
Configure the NTP server (Windows 10):
Windows 10 PC will be an NTP server, and my Ubuntu 22.04 machines will update the time from it as NTP clients.
Recommended by LinkedIn
The local NTP Time Server configuration is complete. Now you can synchronize the time of other devices in your local network.
Configure the NTP client (Ubuntu 22.04):
First, get the IP address of the NTP server.
Proceed to the Ubuntu 22.04 machine.
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install ntp -y
sudo vim /etc/ntp.conf
# Specify one or more NTP servers.server 192.168.56.1 iburst
sudo ufw allow 123/udp
sudo systemctl restart ntp
sudo systemctl status ntp
Network with internet access:
On a network with internet access, you can choose from many NTP servers and connect your devices to one of them.
For example:
Google Public NTP: https://developers.google.com/time
Cloudflare time services: https://www.cloudflare.com/time/
Microsoft NTP server: https://learn.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings?tabs=config
There are many of them, choose your own based on your needs.