Apa itu NTP Server ?
NTP bekerja menggunakan alogaritma Marzullo dengan menggunakkan referensi skala waktu UTC. Pada umumnya sumber waktu yang ada pada jaringan NTP diperoleh dari sumber terpercaya. Misalnya saja radio clock atau atomic clock yang terhubung dengan time server.
Proses dilakukan di dalam jalur komunikasi data menggunakan protocol TCP/IP dan menggunakan port komunikasi User Datagram Protocol (UDP) 123.
Fungsi NTP Server
Sesuai dengan pengertian NTP, maka fungsi dari NTP adalah mengatur dan menyesuaikan (sinkronisasi) waktu antara komputer server dengan komputer client dalam jaringan.
Set Time Zone
Pastikan login menggunakan root dan dapat mengakses server menggunakan SSH, kemudian sesuaikan time zone server
1 2 3 4 5 6 7 8 9 10 11 | [root@iaasweb ~]# timedatectl list-timezones | grep Asia [root@iaasweb ~]# timedatectl set-timezone Asia/Jakarta [root@iaasweb ~]# timedatectl Local time: Tue 2022-11-22 17:35:13 WIB Universal time: Tue 2022-11-22 10:35:13 UTC RTC time: Tue 2022-11-22 10:35:12 Time zone: Asia/Jakarta (WIB, +0700) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a |
Instalasi
Install NTP dan tambahkan pool server indonesia https://www.pool.ntp.org/zone/id
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | [root@iaasweb ~]# yum -y update [root@iaasweb ~]# yum -y install ntp [root@iaasweb ~]# nano /etc/ntp.conf # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.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 [root@iaasweb ~]# firewall-cmd --add-service=ntp --permanent success [root@iaasweb ~]# firewall-cmd --reload success |
Restriction & Logging
Selanjutnya adalah melakukan allowed connection, atau mengijinkan IP range yang dapat menyinkronkan dan mengkueri NTP Server dan melakukan logging yang berfungsi untuk mengecek jika sewaktu-waktu terdapat masalah pada NTP Server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | [root@iaasweb ~]# nano /etc/ntp.conf # Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap restrict 10.177.10.0 mask 255.255.224 nomodify notrap # Disable the monitoring facility to prevent amplification attacks using ntpdc # monlist command when default restrict does not include the noquery flag. See # CVE-2013-5211 for more details. # Note: Monitoring will not be disabled with the limited restriction flag. disable monitor logfile /var/log/ntp.log [root@iaasweb ~]# systemctl status ntpd ● ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2022-11-22 17:40:03 WIB; 1s ago Process: 3193 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 3194 (ntpd) CGroup: /system.slice/ntpd.service └─3194 /usr/sbin/ntpd -u ntp:ntp -g Nov 22 17:40:03 iaasweb.iaas.web.id systemd[1]: Starting Network Time Service... Nov 22 17:40:03 iaasweb.iaas.web.id ntpd[3194]: proto: precision = 0.050 usec Nov 22 17:40:03 iaasweb.iaas.web.id systemd[1]: Started Network Time Service. Nov 22 17:40:03 iaasweb.iaas.web.id ntpd[3194]: 0.0.0.0 c01d 0d kern kernel time sync enabled |
Query & Sync
Ujicoba query & sync pada NTP server untuk melakukan checkup
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | [root@iaasweb ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== +time2.unima.ac. 216.239.35.0 2 u 63 64 177 44.166 9.626 2.488 +time1.unima.ac. 216.239.35.0 2 u 5 64 377 43.939 16.354 4.450 *36.91.114.86 216.239.35.4 2 u 3 64 377 37.184 3.939 4.437 -time.cloudflare 10.227.8.4 3 u 6 64 277 0.964 2.063 3.462 [root@iaasweb ~]# date -R Tue, 22 Nov 2022 17:40:35 +0700 [root@iaasweb ~]# ntpdate -q 0.id.pool.ntp.org 1.id.pool.ntp.org 2.id.pool.ntp.org 3.id.pool.ntp.org server 202.65.114.202, stratum 2, offset 0.011732, delay 0.02655 server 202.162.32.12, stratum 2, offset 0.005423, delay 0.02661 server 203.89.31.10, stratum 3, offset 0.007983, delay 0.04999 server 203.114.224.31, stratum 3, offset 0.006802, delay 0.04735 server 103.123.108.224, stratum 2, offset 0.015366, delay 0.06999 server 103.123.108.223, stratum 2, offset 0.018424, delay 0.07179 server 103.28.56.14, stratum 2, offset 0.008087, delay 0.03514 server 14.102.153.110, stratum 2, offset 0.018768, delay 0.03612 server 162.159.200.1, stratum 3, offset 0.008594, delay 0.02647 server 103.123.108.221, stratum 2, offset 0.016408, delay 0.06979 server 36.91.114.86, stratum 2, offset 0.010277, delay 0.06242 server 103.177.8.14, stratum 3, offset 0.008459, delay 0.05025 server 162.159.200.123, stratum 3, offset 0.008583, delay 0.02654 server 103.123.108.222, stratum 2, offset 0.016173, delay 0.06960 server 202.4.186.250, stratum 2, offset 0.009327, delay 0.06541 server 203.160.128.59, stratum 2, offset 0.035357, delay 0.03835 22 Nov 17:36:57 ntpdate[3179]: adjust time server 202.65.114.202 offset 0.011732 sec [root@iaasweb ~]# ntpstat synchronised to NTP server (103.123.108.221) at stratum 3 time correct to within 118 ms polling server every 256 s |
Setting NTP Client (Linux)
Saya menggunakan Linux CentOS 7 sebagai client NTP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | [root@centos ~]# timedatectl Local time: Tue 2022-11-22 17:49:15 WIB Universal time: Tue 2022-11-22 10:49:15 UTC RTC time: Tue 2022-11-22 10:49:27 Time zone: Asia/Jakarta (WIB, +0700) NTP enabled: n/a NTP synchronized: no RTC in local TZ: no DST active: n/a [root@centos ~]# yum -y install ntp [root@centos ~]# nano /etc/ntp.conf # Permit all access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 restrict ::1 server 10.177.10.14 [root@centos ~]# systemctl start ntpd && systemctl enable ntpd [root@centos ~]# systemctl status ntpd [root@centos ~]# systemctl status ntpd ● ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2022-11-22 19:02:52 WIB; 2min 13s ago Process: 12585 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 12586 (ntpd) CGroup: /system.slice/ntpd.service └─12586 /usr/sbin/ntpd -u ntp:ntp -g Nov 22 19:02:52 centos ntpd[12586]: Listen and drop on 1 v6wildcard :: UDP 123 Nov 22 19:02:52 centos ntpd[12586]: Listen normally on 2 lo 127.0.0.1 UDP 123 Nov 22 19:02:52 centos ntpd[12586]: Listen normally on 3 eth0 10.177.10.10 UDP 123 Nov 22 19:02:52 centos ntpd[12586]: Listen normally on 4 lo ::1 UDP 123 Nov 22 19:02:52 centos ntpd[12586]: Listen normally on 5 eth0 fe80::f30e:83ca:2556:e43f UDP 123 Nov 22 19:02:52 centos ntpd[12586]: Listening on routing socket on fd #22 for interface updates Nov 22 19:02:52 centos ntpd[12586]: 0.0.0.0 c016 06 restart Nov 22 19:02:52 centos ntpd[12586]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM Nov 22 19:02:52 centos ntpd[12586]: 0.0.0.0 c011 01 freq_not_set Nov 22 19:03:00 centos ntpd[12586]: 0.0.0.0 c614 04 freq_mode [root@centos ~]# timedatectl Local time: Tue 2022-11-22 19:05:23 WIB Universal time: Tue 2022-11-22 12:05:23 UTC RTC time: Tue 2022-11-22 12:05:22 Time zone: Asia/Jakarta (WIB, +0700) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a |
Setting NTP Client (Windows)
Saya menggunakan Windows 10 Pro sebagai client NTP. Kemudian, arahkan mouse ke taskbar pada bagian jam/tanggal, lalu klik kanan dan pilih Adjust date/time > Additional date, time, & regional settings > Change time zone > Internet Time > Change settings