Sinkronisasi waktu dengan NTP

NTP (Network Time Protocol) merupakan protokol yang digunakan untuk melakukan time-synchronisation antara host dengan host yang lainnya, sebagai contoh dalam sistem jaringan Kerberos, kecocokan jam antara host satu dengan host yang lainnya mutlak diperlukan, atau antara dedicated loghost dengan firewall, router, multipurpose server dan nids. Catatan singkat ini akan memberikan panduan konfigurasi sistem NTP yang berada di jaringan lokal untuk digunakan sebagai NTP server bagi server lainnya, dan sekaligus bagaimana mengkonfigurasikan sistem yang bertindak sebagai NTP client. Yang diperlukan untuk pertama kalinya adalah:

Konfigurasi di sisi NTP server lokal: edit file konfigurasi ntp.conf, modifikasi isinya kira-kira menjadi seperti ini (silahkan baca manual dari ntp apabila ingin mengetahui referensinya secara lengkap):

# OK with local
# accept local NTP queries
restrict 127.0.0.1

# REMOTE SERVER we sync with
server tock.usno.navy.mil
server clock.isc.org
server tick.usno.navy.mil
restrict tock.usno.navy.mil mask 255.255.255.255 nomodify notrap noquery
restrict clock.isc.org mask 255.255.255.255 nomodify notrap noquery
restrict tick.usno.navy.mil mask 255.255.255.255 nomodify notrap noquery

# CLIENT NETWORK allowed to sync with us
restrict 202.155.20.0 mask 255.255.255.0 nomodify notrust notrap
restrict 202.155.21.0 mask 255.255.255.0 nomodify notrust notrap

# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /etc/ntp/drift

# debugging
#logfile /var/log/ntplog

untuk menguji apakah konektivitas dengan server diluar dapat dilakukan, gunakan perintah ntpdate:

ntpdate clock.isc.org

untuk menguji apakah konfigurasi ntp.conf sudah ok, gunakan ntpq, namun sebelumnya hidupkan proses ntpd nya terlebih dahulu:

ntpq -p

Konfigurasi untuk NTP client, semisal hostaddress NTP server kita adalah time.example.org, isikan ntp.conf menjadi:

# 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


# --- OUR TIMESERVERS ----- 
# or remove the default restrict line 
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.

# restrict mytrustedtimeserverip mask 255.255.255.255 nomodify notrap noquery
# server mytrustedtimeserverip
server time.example.org

#
# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /etc/ntp/drift

#
# Logs
#logfile /var/log/ntplog

note: * konfigurasi ntp diatas tidak menggunakan autentifikasi, tambahkan parameter -A waktu mengeksekusi ntpd * jangan lupa untuk membuka akses udp ke port 123 pada NTP server

Referensi: