Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
89 views

Install NTP Server

This document provides instructions for installing and configuring NTP (Network Time Protocol) on an Ubuntu 18.04 system to synchronize time with public NTP servers or a custom NTP server. It describes downloading the NTP package, editing configuration files to specify NTP servers, and checking the status and synchronization of NTP. Commands are given to install, start, stop, and force syncing with the NTP service.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
89 views

Install NTP Server

This document provides instructions for installing and configuring NTP (Network Time Protocol) on an Ubuntu 18.04 system to synchronize time with public NTP servers or a custom NTP server. It describes downloading the NTP package, editing configuration files to specify NTP servers, and checking the status and synchronization of NTP. Commands are given to install, start, stop, and force syncing with the NTP service.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

# By default, NTP package is available in the Ubuntu 18.04 LTS default repository.

You can install it by just running the following command:


sudo apt-get install ntp -y

# Next, you will need to configure NTP to synchronize its time from public NTP
server. You can do this by editing ntp.conf file:

sudo nano /etc/ntp.conf

# Replace the lines:

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

# With ones that match your location. In my case, I will use the following lines:

pool 0.asia.pool.ntp.org iburst


pool 1.asia.pool.ntp.org iburst
pool 2.asia.pool.ntp.org iburst
pool 3.asia.pool.ntp.org iburst

# A list of available NTP Pool time servers can be found here:


http://support.ntp.org/bin/view/Servers/NTPPoolServers
# Save and close the file. Then, restart the NTP service to apply the changes:

sudo systemctl restart ntp

# You can check the status of NTP with the following command:

sudo systemctl status ntp


Output:
? ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset:
enabled)
Active: active (running) since Fri 2018-10-05 15:10:14 UTC; 42s ago
Docs: man:ntpd(8)
Main PID: 5587 (ntpd)
Tasks: 2 (limit: 1114)
CGroup: /system.slice/ntp.service
??5587 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 113:116

Oct 05 15:10:15 ubuntu1804 ntpd[5587]: Soliciting pool server 123.108.200.124


Oct 05 15:10:16 ubuntu1804 ntpd[5587]: Soliciting pool server 64:ff9b::7b6c:c87c
Oct 05 15:10:16 ubuntu1804 ntpd[5587]: Soliciting pool server 64:ff9b::7b6c:c87c
Oct 05 15:10:18 ubuntu1804 ntpd[5587]: Soliciting pool server
2406:da1a:200:7201:d9ea:9ac5:32e3:339c
Oct 05 15:10:18 ubuntu1804 ntpd[5587]: Soliciting pool server 64:ff9b::7b6c:c87c
Oct 05 15:10:19 ubuntu1804 ntpd[5587]: Soliciting pool server 91.189.91.157
Oct 05 15:10:20 ubuntu1804 ntpd[5587]: Soliciting pool server 91.189.94.4
Oct 05 15:10:21 ubuntu1804 ntpd[5587]: Soliciting pool server 91.189.89.198
Oct 05 15:10:22 ubuntu1804 ntpd[5587]: Soliciting pool server 91.189.89.199
Oct 05 15:10:23 ubuntu1804 ntpd[5587]: Soliciting pool server
2001:67c:1560:8003::c7

# Install and Configure NTP Client


# Now, we will install and configure NTP client to sync time with our NTP server.
# Before starting, you will need to setup /etc/hosts file. So, your NTP server can
be resolved via hostname.
# To do so, open the /etc/hosts file:

sudo nano /etc/hosts

# Add the following lines:

192.168.43.229 ntp-server-host

# Replace the IP address with the IP of your NTP server (the one we installed in
the precious chapter). Save and close the file.
# Next, install NTP and ntpdate with the following command:

sudo apt-get install ntpdate ntp -y

# Now, manually check the time synchronization with your NTP server with the
following command:

sudo ntpdate ntp-server-host

# If everything is fine, you should see the following output:

5 Oct 20:48:49 ntpdate[6067]: adjust time server ntp-server-host offset 0.049526


sec

# Next, you will need to disable the default Ubuntu systemd's timesyncd service.
You can do this with the following command:

sudo timedatectl set-ntp off

# Now, edit /etc/ntp.conf file and set your own configured NTP server as preferred
NTP server for the time synchronization.

sudo nano /etc/ntp.conf

# Add the following lines:

server ntp-server-host prefer iburst

# Save and close the file. Then, restart NTP service to apply the changes:

sudo systemctl restart ntp

# Finally, use the ntpq command to list the NTP time synchronization queue:

ntpq -p

# You should see that ntp-server-host is selected as the current time


synchronization source:

remote refid st t when poll reach delay offset jitter


==============================================================================
fwdns2.vbctv.in 202.73.57.107 4 u 3 64 1 127.437 -142.63 0.000
alphyn.canonica 131.188.3.220 2 u 2 64 1 276.931 -106.99 0.000
ntp-server-host 106.10.186.201 3 u 1 64 1 0.588 161.386 0.000

# To manually force sync


sudo ntpd -q
systemctl restart ntp

You might also like