ntp server configuration on ubuntu 20.04

Network Time Protocol (NTP), used for the purpose of clock synchronization across multiple servers/computers and IT equipment on our network. NTP server is responsible for keeping a set of computers in synchronized mode with each other. On our local network, the servers should be able to keep all client systems to within a single millisecond with each other.

So have this kind of setup and configuration in our network environment it’s necessary that, the systems need to start or stop a task in unison at a precise time.

Here we will explain step by step guide to show you ‘how to configure an NTP server on Ubuntu 22.04’ and also how to configure command for client system to sync its system time with specific NTP server running on our network.

Firstly to start we have to install the NTP package using apt-get

#apt update #apt install ntp

Configuration of NTP Service we have to edit /etc/ntp.conf

#vi /etc/ntp.conf

Here we can see some default pools of NTP server available globally but we can change these lines with server pools from your own country and time zone. The less latency between your location and a NTP server, We choose from the NTP Pool Project website to find the best nearest NTP server pool for our location and change the entries in this file.

But here we have to remember one of the important part of NTP implement is that we have to change our TIME ZONE according to our location/country.

Changing the Timezone Using the timedatectl Command

Before changing the timezone, we need to find out the long name for the timezone we want to use. The timezones are using “Region/City” format.

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or invoke the timedatectl command with the list-timezones option:

#timedatectl list-timezones

When we identify our time zone is accurate to your location, run the following command as root user: for example as I am in India.

#timedatectl set-timezone Asia/Kolkata

Now let’s check with this command.

#timedatectl

root@ntp:~# timedatectl
Local time: Thu 2022-04-28 16:08:49 IST
Universal time: Thu 2022-04-28 10:38:49 UTC
RTC time: Thu 2022-04-28 10:38:49
Time zone: Asia/Kolkata (IST, +0530)
System clock synchronized: yes
NTP service: n/a
RTC in local TZ: no

#systemctl restart ntp

Now on client side run this command to sync your machine time with NTP server.

#ntpdate -u 192.168.x.x

root@ntp ~]# ntpdate -u 192.168.x.x
27 Apr 13:52:56 ntpdate[81478]: adjust time server 192.168.x.x offset -0.009784 sec
[root@ntp ~]# date

Thu Apr 28 16:13:01 IST 2022

Related Post

Leave a Reply

Your email address will not be published.