Change NTP servers on clean Ubuntu 18.04 server installation

In clean Ubuntu 18.04 server installation it is no longer required to install ntp package separately as systemd has embedded timesynd to sync time via NTP. By default, Ubuntu uses ntp.ubuntu.com pool.

You can check status:

timedatectl status

                      Local time: Sun 2018-05-20 21:01:40 CEST
                  Universal time: Sun 2018-05-20 19:01:40 UTC
                        RTC time: Sun 2018-05-20 19:01:42
                       Time zone: ETC/UTC (UTC, +0000)
       System clock synchronized: no
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

and check sync status of NTP sync

systemctl status systemd-timesyncd

● systemd-timesyncd.service - Network Time Synchronization
  Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Active: active (running) since Sun 2018-05-20 20:50:45 UTC; 2min 0s ago
    Docs: man:systemd-timesyncd.service(8)
Main PID: 15735 (systemd-timesyn)
  Status: "Synchronized to time server 91.189.91.157:123 (ntp.ubuntu.com)."
   Tasks: 2 (limit: 1113)
  CGroup: /system.slice/systemd-timesyncd.service
          └─15735 /lib/systemd/systemd-timesyncd

May 20 20:56:37 host3 systemd[1]: Starting Network Time Synchronization...
May 20 20:56:37 host3 systemd[1]: Started Network Time Synchronization.
May 20 20:56:37 host3 systemd-timesyncd[15735]: Synchronized to time server 91.189.91.157:123 (ntp.ubuntu.com).

Last line and status both clearly show NTP sync status that was successful.

 

To change list of NTP servers, it is necessary to change systemd-timesyncd’s configuration:

/etc/systemd/timesyncd.conf

Let’s change it and add time1.stupi.se as NTP server:

 mcedit /etc/systemd/timesyncd.conf

change the line

#NTP

to

NTP=time1.stupi.se

restart systemd-timesyncd

systemctl restart systemd-timesyncd

and check status of NTP sync

systemctl status systemd-timesyncd

● systemd-timesyncd.service - Network Time Synchronization
  Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Active: active (running) since Sun 2018-05-20 20:56:37 UTC; 7s ago
    Docs: man:systemd-timesyncd.service(8)
Main PID: 15735 (systemd-timesyn)
  Status: "Synchronized to time server 192.36.143.150:123 (time1.stupi.se)."
   Tasks: 2 (limit: 1113)
  CGroup: /system.slice/systemd-timesyncd.service
          └─15917 /lib/systemd/systemd-timesyncd

May 20 20:56:37 host3 systemd[1]: Starting Network Time Synchronization...
May 20 20:56:37 host3 systemd[1]: Started Network Time Synchronization.
May 20 20:56:37 host3 systemd-timesyncd[15735]: Synchronized to time server 192.36.143.150:123 (time1.stupi.se).

We successfully changed NTP settings on clean Ubuntu 18.04 server installation with no additional packages installed.

 

Ask a question in comments if you haven’t found what you were looking for

 

 

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s