I'm fairly new to NTP. I have two computers running Lubuntu 17.04 that I'd like to keep in close time sync with minimal hardware. There is no need to sync to real time, just to keep the system times between the two computers as close as possible.
NTP seems to an appropriate solution. I succeeding in getting NTP working between the two computers, when configured with DHCP addresses (DHCP from a router, one PC is the NTP broadcast server and the other is the client, the PCs sync to each other and obtain close sync of ~1ms or less).
To reduce the amount of hardware I remove the router and set the IP's on each computer to static, then connect via a cross-over cable:
- 10.1.1.50 255.255.255.0 (NTP "client" PC)
- 10.1.1.51 255.255.255.0 (NTP "server" PC)
(Gateway was left blank in both cases.)
The PCs can ping each other successfully (delay is less than 1ms, around 0.3ms-0.4ms). However, I can't seem to get the ntp.conf
configured; the NTP client computer just stays on INIT and all measures at 0. How can I debug the NTP configuration to find out where it is going wrong please?
There is no /var/lib/ntp/ntp.conf.dhcp
file.
Firewall is turned off for both PCs.
Output from ntpq -pn
is
remote refid st t when poll reach delay offset jitter
==============================================================================
10.1.1.51 .INIT. 16 u - 1024 0 0.000 0.000 0.000
Relevant lines from ntp.conf
for the client are (i.e., all lines without comments)
driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 10.1.1.51
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
restrict 127.0.0.1
restrict ::1
restrict 10.1.1.0 mask 255.255.255.0
disable auth
broadcastclient
Relevant lines from ntp.conf for the server NTP PC are (i.e., all lines without comments)
driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 127.127.2.1 # local clock
fudge 127.127.2.1 stratum 10
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
restrict 127.0.0.1
restrict ::1
restrict source notrap nomodify noquery
restrict 10.1.1.0 mask 255.255.255.0
broadcast 10.1.1.255
Using the command ntpdate -d 10.1.1.51 the problem seems to be that the NTP server 10.1.1.51 has too high a stratum level (as it is currently disconnected from the internet, and hence, it is not a trustworthy time source according to NTP).
Research suggests that it is not possible to fudge the stratum level of my isolated NTP server. Hence, I've enabled wifi on the NTP server and have attempted to allow it to sync to the standard Ubuntu pool of time servers, however ntpq -p takes a long time to respond with the cross over cable plugged in. I will check if my network config is correct and report back.
Answer
To use NTP via a cross-over cable, the NTP server PC has to be synchronising to other internet servers, otherwise its own stratum level drops too low and the client NTP PC rejects it as a valid server. In my case the solution was:
Ensure cross over cable is set up correctly, both wired NICs should have no gateway and no DNS configured, and also be on a different subnet to the NTP server's wifi subnet. e.g. in my case, I moved the PC NICs to static IPs of
- 10.1.2.50 255.255.255.0 (NTP "client" PC) No gateway, no DNS
- 10.1.2.51 255.255.255.0 (NTP "server" PC) No gateway, no DNS
This is done in the Lubuntu "Edit Connections" GUI networking tool.
Enable wifi on the NTP server PC, this allows it to get time synch from the internet. This is configured to the 10.1.1.n subnet, where n is allocated via DHCP from the wifi router. This has to be a different subnet from the wired NICs as discovered per https://askubuntu.com/questions/624830/ubuntu-using-wrong-nic-for-internet-connection
Add the standard time servers that ship with the default
ntp.conf
file back in and ensure bothntp.conf
files (client and server) are looking at the 10.1.2.0 subnet. Reboot everything and wait ten minutes for the NTP to start synchronising.
No comments:
Post a Comment