authoryanuarakhid - 24 Mei 2021 • Baca 4 Menit

Tutorial Ubuntu 20.04 LTS : Cara Instalasi dan Konfigurasi NTP (Network Time Protocol) Server Menggunakan NTPd


Tutorial Ubuntu 20.04 LTS : Cara Instalasi dan Konfigurasi NTP (Network Time Protocol) Server Menggunakan NTPd

NTP (Network Time Protocol) merupakan protocol jaringan yang digunakan untuk sinkronasi waktu baik didalam jaringan LAN (Local Area Network) maupun Internet. Umumnya port yang digunakan oleh protocol ini adalah UDP 123. Pada postingan kali ini akan membahas mengenai tutorial cara instalasi dan konfigurasi NTP Server pada Sistem Operasi Ubuntu 20.04 LTS menggunakan NTPd.

Install


Sebelum melakukan instalasi paket aplikasi terlebih dahulu lakukan update dan upgrade sistem.

$ sudo apt update && sudo apt upgrade

Untuk melakukan instalasi paket NTP cukup ketikan perintah berikut.

$ sudo apt install ntp

Config


$ sudo nano /etc/ntp.conf

Secara default NTP Server memakai pool ntp default.

# 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

# Use Ubuntu's ntp server as a fallback.
pool ntp.ubuntu.com

Kita akan ubah Pool Default tersebut menjadi menggunakan pool ntp khusus Wilayah Indonesia.

NTP Pool Wilayah Indonesia
NTP Pool Wilayah Indonesia - Source : https://www.pool.ntp.org/zone/id

Kita disable pool default ubuntu dengan memberikan comment (#). Lalu kita tambahkan pool Wilayah Indonesia tersebut kedalam file /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
server 0.id.pool.ntp.org
server 1.id.pool.ntp.org
server 2.id.pool.ntp.org
server 3.id.pool.ntp.org

# Use Ubuntu's ntp server as a fallback.
#pool ntp.ubuntu.com

Jangan lupa disekitar line berikut kita tambahkan Network mana yang boleh untuk menggunakan NTP Server yang kita buat. Sebagai contoh karena Saya menggunakan LAN (Local Area Network) 10.1.1.0/24 maka saya cukup menambahkan restrict 10.1.1.0 mask 255.255.255.0 nomodify notrap. Jika kalian mempunyai lebih dari 1 LAN Network maka tinggal kita definisikan saja network yang diinginkan dibawahnya.

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Needed for adding pool entries
restrict source notrap nomodify noquery

restrict 10.1.1.0 mask 255.255.255.0 nomodify notrap

Setelah konfigurasi selesai maka terakhir jangan lupa untuk melakukan restart service NTP.

$ sudo systemctl restart ntp

Untuk melihat status pada NTP Server bisa menggunakan command berikut.

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 2.ntp.maxindo.n 203.123.48.219   2 u   21   64    1   56.378    7.619   0.000
 time.cloudflare 10.35.14.16      3 u   19   64    1   70.717   -2.445   0.000
 103.123.108.189 216.239.35.4     2 u   22   64    1  106.519    3.610   0.000
 ntp.skyline.net 133.243.238.164  2 u   29   64    1   67.184   -5.680   0.000

Pengujian


Pengujian NTP Server ini kita uji dalam 2 Sistem Operasi yaitu Windows dan Linux.

Pada Sistem Operasi Windows

Untuk melakukan sinkronasi waktu melalui NTP Client dengan menggunakan NTP Server yang kita buat adalah sebagai berikut.

NTP Client Sistem Operasi Windows

Pada Sistem Operasi Linux (Ubuntu Distro)

$ sudo nano /etc/systemd/timesyncd.conf

Pengujian NTP Client ini dilakukan pada sistem operasi Ubuntu. Dengan cara mengubah file /etc/systemd/timesyncd.conf pada bagian NTP= kita lakukan enable dengan mehapus tanda # dan menambahkan alamat IP NTP Server.

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See timesyncd.conf(5) for details.


[Time]
NTP=10.1.1.18
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048

Setelah itu lakukan restart service systemd-timesyncd

$ sudo systemctl restart systemd-timesyncd

Untuk melihat status NTP Client dapat dicek menggunakan perintah berikut.

$ timedatectl timesync-status
       Server: 10.1.1.18 (10.1.1.18)
Poll interval: 4min 16s (min: 32s; max 34min 8s)
 Packet count: 0

Demikian tutorial mengenai cara instalasi dan konfigurasi NTP Server menggunakan NTPd pada sistem operasi Ubuntu 20.04 LTS. Happy Config!! 😉

Tentang Penulis‎ ‏‏

author

Akhid Yanuar A.F

Linux System Administration | Computer Network | Operating System | Cloud Computing | IT Security | Linux Enthusiast 🐧

Find Me