0

I have a Centos 5(I know that Centos5 is very very old) virtual machine that is refusing to sync. My virtual machine host is Windows 10 with HyperV and is syncing without problems.

Things that I have tried:

  1. Restart the vm.
  2. Disable the vm firewall.
  3. Compare ntpd.conf to a remote ntpd.conf that is working and is Centos 5 too.
  4. Enable HyperV integration services
  5. Enable HyperV time sync service
  6. Install all Windows updates.

Here is an extract of my /var/log/messages:

[root@evtest etc]# cat /var/log/messages | grep "ntpd"
Jul  5 15:10:03 evtest ntpd[2174]: ntpd exiting on signal 15
Jul  6 01:44:26 evtest ntpd[2174]: ntpd [email protected] Sat Dec 20 02:52:11 UTC 2014 (1)
Jul  6 01:44:26 evtest ntpd[2175]: precision = 1.000 usec
Jul  6 01:44:26 evtest ntpd[2175]: Listening on interface wildcard, 0.0.0.0#123 Disabled
Jul  6 01:44:26 evtest ntpd[2175]: Listening on interface lo, 127.0.0.1#123 Enabled
Jul  6 01:44:26 evtest ntpd[2175]: Listening on interface eth0, 192.168.1.36#123 Enabled
Jul  6 01:44:26 evtest ntpd[2175]: kernel time sync status 0040
Jul  6 01:44:26 evtest ntpd[2175]: getaddrinfo: "::1" invalid host address, ignored
Jul  6 01:44:26 evtest ntpd[2175]: frequency initialized 2.488 PPM from /var/lib/ntp/drift
Jul  6 01:47:47 evtest ntpd[2175]: synchronized to LOCAL(0), stratum 10
Jul  6 01:47:47 evtest ntpd[2175]: kernel time sync enabled 0001
Jul  6 14:30:39 evtest ntpd[2175]: ntpd exiting on signal 15
Jul  7 00:16:54 evtest ntpd[2174]: ntpd [email protected] Sat Dec 20 02:52:11 UTC 2014 (1)
Jul  7 00:16:54 evtest ntpd[2175]: precision = 1.000 usec
Jul  7 00:16:54 evtest ntpd[2175]: Listening on interface wildcard, 0.0.0.0#123 Disabled
Jul  7 00:16:54 evtest ntpd[2175]: Listening on interface lo, 127.0.0.1#123 Enabled
Jul  7 00:16:54 evtest ntpd[2175]: Listening on interface eth0, 192.168.1.36#123 Enabled
Jul  7 00:16:54 evtest ntpd[2175]: kernel time sync status 0040
Jul  7 00:16:54 evtest ntpd[2175]: getaddrinfo: "::1" invalid host address, ignored
Jul  7 00:16:56 evtest ntpd[2175]: frequency initialized 2.488 PPM from /var/lib/ntp/drift
Jul  7 00:20:12 evtest ntpd[2175]: synchronized to LOCAL(0), stratum 10
Jul  7 00:20:12 evtest ntpd[2175]: kernel time sync enabled 0001


Here is and extract of the remote /var/log/messages:

[root@centos5 etc]# cat /var/log/messages.1 | grep "ntpd"
Jun 29 20:25:13 centos5 ntpd[3301]: ntpd exiting on signal 15
Jun 29 20:44:25 centos5 ntpd[3298]: ntpd [email protected] Sat Dec 20 02:52:11 UTC 2014 (1)
Jun 29 20:44:25 centos5 ntpd[3299]: precision = 1.000 usec
Jun 29 20:44:25 centos5 ntpd[3299]: Listening on interface wildcard, 0.0.0.0#123 Disabled
Jun 29 20:44:25 centos5 ntpd[3299]: Listening on interface lo, 127.0.0.1#123 Enabled
Jun 29 20:44:25 centos5 ntpd[3299]: Listening on interface eth0, 1.10.100.57#123 Enabled
Jun 29 20:44:25 centos5 ntpd[3299]: kernel time sync status 0040
Jun 29 20:44:25 centos5 ntpd[3299]: getaddrinfo: "::1" invalid host address, ignored
Jun 29 20:44:26 centos5 ntpd[3299]: frequency initialized 39.595 PPM from /var/lib/ntp/drift
Jun 29 20:47:41 centos5 ntpd[3299]: synchronized to LOCAL(0), stratum 10
Jun 29 20:47:41 centos5 ntpd[3299]: kernel time sync enabled 0001
Jun 29 20:49:51 centos5 ntpd[3299]: synchronized to 192.36.143.130, stratum 1
Jun 29 21:09:14 centos5 ntpd[3299]: time reset +2.461477 s
Jun 29 21:13:01 centos5 ntpd[3299]: synchronized to LOCAL(0), stratum 10
Jun 29 21:15:10 centos5 ntpd[3299]: synchronized to 192.36.143.130, stratum 1
Jul  3 18:52:20 centos5 ntpd[3299]: ntpd exiting on signal 15
Jul  3 22:08:54 centos5 ntpd[3299]: ntpd [email protected] Sat Dec 20 02:52:11 UTC 2014 (1)
Jul  3 22:08:54 centos5 ntpd[3300]: precision = 1.000 usec
Jul  3 22:08:54 centos5 ntpd[3300]: Listening on interface wildcard, 0.0.0.0#123 Disabled
Jul  3 22:08:54 centos5 ntpd[3300]: Listening on interface lo, 127.0.0.1#123 Enabled
Jul  3 22:08:54 centos5 ntpd[3300]: Listening on interface eth0, 1.10.100.57#123 Enabled
Jul  3 22:08:54 centos5 ntpd[3300]: kernel time sync status 0040
Jul  3 22:08:54 centos5 ntpd[3300]: getaddrinfo: "::1" invalid host address, ignored
Jul  3 22:08:55 centos5 ntpd[3300]: frequency initialized 37.845 PPM from /var/lib/ntp/drift
Jul  3 22:12:08 centos5 ntpd[3300]: synchronized to LOCAL(0), stratum 10
Jul  3 22:12:08 centos5 ntpd[3300]: kernel time sync enabled 0001
Jul  3 22:14:16 centos5 ntpd[3300]: synchronized to 45.231.168.6, stratum 2
Jul  3 22:29:31 centos5 ntpd[3300]: time reset +15.928958 s
Jul  3 22:33:42 centos5 ntpd[3300]: synchronized to LOCAL(0), stratum 10
Jul  3 22:34:17 centos5 ntpd[3300]: synchronized to 45.231.168.6, stratum 2
Jul  3 23:17:50 centos5 ntpd[3300]: synchronized to 41.220.128.73, stratum 2
Jul  3 23:33:59 centos5 ntpd[3300]: synchronized to 193.182.111.13, stratum 2
Jul  3 23:38:16 centos5 ntpd[3300]: synchronized to 45.231.168.6, stratum 2
Jul  4 00:00:48 centos5 ntpd[3300]: synchronized to 41.220.128.73, stratum 2
Jul  4 00:08:13 centos5 ntpd[3300]: synchronized to 45.231.168.6, stratum 2
Jul  4 00:13:02 centos5 ntpd[3300]: synchronized to 41.220.128.73, stratum 2
Jul  4 00:15:57 centos5 ntpd[3300]: synchronized to 45.231.168.6, stratum 2
Jul  4 00:16:13 centos5 ntpd[3300]: synchronized to 193.182.111.13, stratum 2
Jul  4 00:48:05 centos5 ntpd[3300]: synchronized to 41.220.128.73, stratum 2
Jul  4 03:07:45 centos5 ntpd[3300]: synchronized to 45.231.168.6, stratum 2

As you see, the remote messages file have several "synchronized to" lines but those lines doesn`t appear in my messages file.

How do I enable time syncronization?

EDIT1:

[root@evtest etc]# echo "peers" | ntpq
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 karhu.miuku.net .INIT.          16 u    - 1024    0    0.000    0.000   0.000
 ntp2.flashdance .RMOT.          16 u    - 1024    0    0.000    0.000   0.000
*LOCAL(0)        .LOCL.          10 l   24   64  377    0.000    0.000   0.001
[root@evtest etc]#

EDIT2: I'd rather like to use ntpd

EDIT3:

[root@evtest etc]# cat /etc/ntp.conf
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery

# 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 -6 ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# 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
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
server 3.centos.pool.ntp.org

#broadcast 192.168.1.255 key 42         # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 key 42             # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 key 42  # manycast client

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0
fudge   127.127.1.0 stratum 10

# 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 /var/lib/ntp/drift

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8
restrict 0.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 1.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 2.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 3.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
[root@evtest etc]#

EDIT4:

[root@evtest etc]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

[root@evtest etc]#


EDIT5: Working (remote) system clock (this would be the correct time):

Thu Jul  8 08:19:36 CDT 2021

My (incorrect) clock:

Thu Jul  8 01:08:51 CDT 2021

EDIT6: Output of tcpdump -ni eth0 'udp port 123'


[root@evtest ~]# tcpdump -ni eth0 'udp port 123'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
09:16:26.065503 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
09:16:30.064984 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length                                                                                                                                                        48
09:33:30.065630 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
09:33:33.064632 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length                                                                                                                                                        48
09:50:35.065585 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
09:50:39.065966 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length                                                                                                                                                        48
10:07:40.065476 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
10:07:42.065569 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
10:24:44.065691 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
10:24:45.066300 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
10:41:49.065627 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
10:41:50.065270 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
10:58:54.065499 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
10:58:55.065089 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
11:15:58.065713 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
11:15:59.065277 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
11:33:01.065423 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
11:33:05.064858 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
11:50:07.065780 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
11:50:09.066043 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
12:07:11.065087 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
12:07:14.065845 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
12:24:16.064951 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
12:24:18.065121 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
12:41:21.065706 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
12:41:21.065719 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
12:58:24.065325 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
12:58:25.064950 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
13:15:29.066151 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
13:15:31.066342 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
13:32:32.065751 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
13:32:37.065828 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
13:49:35.065384 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
13:49:41.065109 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
14:06:41.065836 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
14:06:47.066553 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
14:23:44.065511 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
14:23:51.065093 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
14:40:47.066145 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
14:40:55.065992 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
14:57:50.065718 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
14:57:58.065650 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
15:14:55.064675 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
15:15:01.065336 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48
15:32:01.065972 IP 192.168.1.36.ntp > 195.3.254.2.ntp: NTPv4, Client, length 48
15:32:07.065768 IP 192.168.1.36.ntp > 192.36.143.130.ntp: NTPv4, Client, length 48




5

2 Answers 2

1

Your remote peers are unreachable. This might be because of a local restriction in /etc/ntp.conf, a local firewall setting, or an upstream firewall setting or connectivity issue between you and your NTP servers.

The contents of your /etc/ntp.conf and iptables diagnostics indicate that the problem isn't likely your local configuration. Your tcpdump -ni eth0 'udp port 123' confirms that the packets are leaving your system successfully, but aren't being replied to.

So it seems like you have an upstream connectivity problem.

0

This is how I solved the problem:

1.-I adjusted the clock by hand with:

ntpdate -u  1.centos.pool.ntp.org

2.-I created a cron job to sync my clock once every hour:

crontab -l
59 * * * * /sbin/ntpdate -u  1.centos.pool.ntp.org >> /root/timesync.txt

2
  • That's a bad solution. You risk stepping the time, leading to all kinds of weird behavior. One of the good things about ntpd is that it disciplines the local clock, by slowing it or speeding it up. Thus, you will never have steps in time. In addition it will poll less often as it learns how local clock behaves. It's generally better to fix problems than create ugly workarounds.
    – vidarlo
    Jul 17, 2021 at 21:16
  • Is there a way to change the udp port that ntpd uses for communication? Udp port 123 is being blocked. Jul 19, 2021 at 21:16

Not the answer you're looking for? Browse other questions tagged .