How To Install NTPd Ubuntu 16.04

Step 1: Install NTPd

1.1 Run commands in root

sudo su

1.2 Run update / upgrade

sudo apt-get update && apt-get upgrade -y
root@ubuntu:/# sudo apt-get update && apt-get upgrade -y
Hit:1 http://se.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://se.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 http://se.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@ubuntu:/# ^C
root@ubuntu:/#

1.3 Install NTP daemon

sudo apt-get install ntp -y
Unpacking ntp (1:4.2.8p4+dfsg-3ubuntu5.9) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21.5) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libopts25:amd64 (1:5.18.7-3) ...
Setting up ntp (1:4.2.8p4+dfsg-3ubuntu5.9) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.5) ...
Processing triggers for ureadahead (0.100.0-19) ...
root@ubuntu:/#

1.4 Configure NTP Server

sudo nano /etc/ntp.conf
# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
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
# Change to your preferred NTP servers our leave the defaults

# 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

pool 0.se.pool.ntp.org
pool 1.se.pool.ntp.org
pool 2.se.pool.ntp.org
pool 3.se.pool.ntp.org

Add a log file statement which will record all NTP server issues

# Scroll down to the end and add the fallowing statement

logfile /var/log/ntp.log

Exit and Save

1.5 Restart ntpd

sudo systemctl restart ntp

1.6 Verify ntpd for status information

sudo ntpq -p
root@ubuntu:/# sudo ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.se.pool.ntp.o .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.se.pool.ntp.o .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.se.pool.ntp.o .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.se.pool.ntp.o .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp2.flashdance 192.36.143.151   2 u    6   64    1   11.438   -1.855   0.000
 ntp5.flashdance 194.58.202.20    2 u    7   64    1   13.526   -1.217   0.000
 c83-248-232-211 10.0.105.223     2 u    4   64    1   16.527   -7.597   0.000
 ntp4.flashdance 194.58.202.148   2 u    6   64    1    8.385   -3.445   0.000
 ntp.keff.org    .PPS.            1 u    6   64    1   12.404   -2.047   0.000
 ntp1.flashdance 194.58.202.148   2 u    9   64    1   11.167   -2.034   0.000
 mail.sturupclou 193.11.166.36    2 u    9   64    1    9.101   -3.332   0.000
 178.73.198.130  17.253.54.253    2 u   10   64    1   10.872   -1.272   0.000
 ntp8.flashdance 194.58.202.20    2 u    8   64    1   24.496    0.769   0.000
 time4.stupi.se  .PPS.            1 u    8   64    1    8.213   -3.380   0.000
 54.34.227.87.st .PPS.            1 u    9   64    1   15.201   -3.027   0.000
 ntp7.flashdance 194.58.202.148   2 u    7   64    1   11.372   -2.323   0.000
 pugot.canonical 140.203.204.77   2 u    6   64    1   41.895   -3.267   0.000
 golem.canonical 193.79.237.14    2 u    6   64    1   43.125   -3.939   0.000
root@ubuntu:/#

1.7 Verify time and date

sudo timedatectl status
root@ubuntu:/# sudo timedatectl status
      Local time: Sat 2018-11-03 00:36:19 CET
  Universal time: Fri 2018-11-02 23:36:19 UTC
        RTC time: Fri 2018-11-02 23:36:19
       Time zone: Europe/Stockholm (CET, +0100)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no
root@ubuntu:/#

1.8 Allow NTPd traffic in firewall

sudo ufw allow 123/udp
root@ubuntu:/# sudo ufw allow 123/udp
Rule added
Rule added (v6)
root@ubuntu:/#

Donate