Tuesday, 17 December 2024

How to setup NTP server in ubuntu20?

Reference: https://www.digitalocean.com/community/tutorials/how-to-set-up-time-synchronization-on-ubuntu-20-04 


First, run apt update to refresh your local package index:

  1. sudo apt update

Then, run apt install ntp to install this package:

  1. sudo apt install ntp

ntpd will begin automatically after your installation completes. You can verify that everything is working correctly by querying ntpd for status information:

  1. ntpq -p


If you want to setup a local server:

  1. sudo vim /etc/ntp.conf
  2. ---
  3. # Point to our network's master time server
    server 192.168.1.234 iburst
    restrict default
    driftfile /var/lib/ntp/ntp.drift
    minpoll 4
    maxpoll 5

Then, you can create a drift file as following:

  1. sudo vim /var/lib/ntp/ntp.drift
  2. ---
  3. 0.000

Finally you can restart the service:

  1. sudo service ntp restart
  2. sudo service ntp status