I have a local net with no internet and want to keep all computers in there time synced. I do not care about the absolute time, it should just be the same for all.
I found several posts about this. The most useful ones were:
server
I did setup the server with the IP 192.168.1.123 and it seems to be working ok: The deamon "ntpd" is running and I had been adding in etc/ntp.conf the lines
# this sets the source to local time
server 127.127.1.0
fudge 127.127.1.0 stratum 8
# this makes the ntpd deamon to send out its time on the local net.
broadcast 192.168.255.255
I verified it with the ntpq command:
ntpq -c lpeer
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.255.255 .BCST. 16 B - 64 0 0.000 0.000 0.000
"BCST" says its in broadcast more and the IP shows its broadcasting to all computers on the local net (a B class network, thus 2x 255).
client
On client side I also installed ntp, and used the default /etc/ntp.conf and added the lines
server 192.168.1.123 iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 8
where 192.168.1.123 is the local IP of the server broadcasting and the other line should tell the client (a laptop) to use its own clock when the network connection is off. I restarted the service on the client and ran ntpq to check the connection
ntpq -c lpeer
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.1.123 .INIT. 16 u 1 64 0 0.000 0.000 0.000
LOCAL(0) .LOCL. 8 l 6 64 1 0.000 0.000 0.000
Repeating this command I can see the "when" column counting up both and starting with 0 again when reaching 64sec. I did expect after the 64 sec this would change to this:
ntpq -c lpeer
remote refid st t when poll reach delay offset jitter
==============================================================================
*192.168.1.123 .INIT. 16 u 1 64 0 0.000 0.000 0.000
LOCAL(0) .LOCL. 8 l 6 64 1 0.000 0.000 0.000
Note the "*" before the server IP. But it did not. What I got after about 1hr was
ntpq -c lpeer
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.1.123 .INIT. 16 u 1 64 0 0.000 0.000 0.000
*LOCAL(0) .LOCL. 8 l 63 64 377 0.000 0.000 0.000
I think this tells me, there are 2 sources for NTP configured, but as the remote source is not working/not available/whatever it is not used and the fallback case local clock is used, but I am not sure if that interpretation is correct.
what I tried
I waited more than 1hr, I restarted the ntpd
serveral times with sudo /etc/init.d/ntp restart
and I also rebooted. Further I commented out the local section clock so that the only server was server 192.168.1.123
. I could not get that "*" to appear. Also I saw a section in the ntp.conf that said
#if you want to listen to time broadcasts on you local subnet,
#de-comment the next lines. Please do this only if you trust
#everybody on the network!
#disable auth
#broadcastclient
I tried un-commenting and restarting the service but still that star did not appear. I am wondering about the last section, though, because this section did turn up in any other post or internet result that I saw on the ntp configuration. There are several ones on local setups and most seem to be find with the server address alone. Ping from client to server is fine. There is not firewall etc.
question
I am out of ideas. I think I have a server with fully working ntp server which is sending out the time. But I do have a client which is failing to receive the time information from the server.
What can I do to get the client running?
The problem was resolved, the system works now. I do this summary for myself and any others who need to setup an offline NTP server (again). The actual problem seemed to be that the experimentation with the broadcast mode broke the ntpd on the server, it again worked on another server restart. Why it did not work when I followed the above given posts I am not really sure.
Backgound
Part of the problem was that I did not understand how NTP works and what I was doing. Neither man page nor the server guide 16.04 gave a simplified overview on the different computers work together. First, NTP client and server is misleading. Its always the same program, the NTP deamon, "ntpd". It must be installed on every computer on the local network for the time synchronisation to work. I did not check about the windows clients yet but I am sure there is a version for them somewhere as well (please comment if you have info about it - build in functions would be preferred). The offline system would work on system clocks only. Its beneficial to use several system clocks, not only the main server, because each clock adds to reduce the time drift. In other words, one clock would make all computers synchronised, but absolute time in more stable and precise when more clocks are considered. From what I read 4 should be a good number. NTP can act as server and as client at the same time. The default configuration file does not really have a configuration section for the server role. As simple model, each
ntpd
instance is a client which gets time information from somewhere by regular polling it. Either polling anotherntpd
or polling the local onboard clock. It becomes a server when is answers polls from others. For example a network connected by a proxy server to the internet. That proxy server would runntpd
to poll several internet NTP servers and thus snyc its own time to them. When all local clients poll that proxy server for its (synchonised) time and it starts answering the polls, it becomes and NTP server itself. Out offline case is exactly that, except the online servers are replaced by the onboard clock.Configuration For the setup the
/etc/ntp.conf
file must be edited. The default is quite full of stuff. I deleted all except:The server in that example has the IP 192.168.1.111. This config can be the same for all PCs on the network. Only comment out the local clock section on clients which are not laptops. The line should be kept on laptops and other devices that may operate off the net for some time. The first server section should be commented out on the server.
After editing restart the service with the start/stop script
For checking run
ntpd -p
its a bit shorter than the version in the question and gives the same output. There is a
*
before the clock line to indicate that its being used. Here the output for a working server:The when column is counting up, the reach is anything >0. Here the output for a working client:
If you yet refid=
.INIT.
it does not work. The numbers would differ obviously. The clients should not show 0.000 0.000 0.000 values. An output for a client with additional configured fall back clock (note its not being used right now - no*
):added infos The default config describes a broadcast send and a broadcast receive option. Do not activate this for normal operation. It is not required to get the system going and to configure client and server. If anything gets stuck do not only restart the service, but reboot fully. Even an ubuntu server. When the system did not run, I noted that
ps -e |grep ntp
should 2 'ntpd' processes. The pair could be started and stopped consistently. The running version only showed one on each computer. There are other restriction options and logging option from the default config file that might be useful. Did not test them.Hopefully that becomes useful at some time. If you have corrections, please comment, I will try to update the answer.
CatMan
PS: Big thanks to Ken Mollerup, whose comments lead me to a better understanding of the NTP system.
Ntpd is a server and ntpdate is a client. Correct config should enable ntpd working and all clients get updated from it. I don't agree on the way that ntpd is installed on every client machine. Intalling ntpd on all other systems as clients is quite cumbersome.
Moreover you get averaged time from several servers. It might be useful sometimes but I can't see necessity in your case. The updated time will gradually lose precision if a server has time drift.