timedatectl

Problem

An ubuntu server 16.04 time was not being synchronized. Here was the error in the syslog:


timesyncd[26781]: Timed out waiting for reply from [2001:67c:1560:8003::c8]:123 (ntp.ubuntu.com)

 

When I checked time timedatectl NTP synchronized was showing as off and when I tried to turn it on it wasn’t changing state.


# timedatectl
Local time: Mon 2019-01-21 10:49:54 XXX
Universal time: Mon 2019-01-21 07:49:54 UTC
RTC time: Mon 2019-01-21 07:53:45
Time zone: One/Two (XXX, +0300)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no

# timedatectl set-ntp on
# timedatectl
Local time: Mon 2019-01-21 10:54:41 XXX
Universal time: Mon 2019-01-21 07:54:41 UTC
RTC time: Mon 2019-01-21 07:58:32
Time zone: One/Two (XXX, +0300)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
# timedatectl
Local time: Mon 2019-01-21 11:12:14 XXX
Universal time: Mon 2019-01-21 08:12:14 UTC
RTC time: Mon 2019-01-21 08:16:05
Time zone: One/Two (XXX, +0300)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no

Solution

I needed to update the firewall settings and allow outgoing traffic for the ntp port. After this the time was synchronized:


systemd[1185]: Time has been changed

Then when you check timedatectl


# timedatectl
Local time: Mon 2019-01-21 11:35:04 XXX
Universal time: Mon 2019-01-21 08:35:04 UTC
RTC time: Mon 2019-01-21 08:35:04
Time zone: One/Two (XXX, +0300)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

References

How To Set Up Time Synchronization on Ubuntu 16.04

How to use ntpdate behind a proxy?