
At work, I’m in charge of 20 individual build systems for one of our larger software project (18 Linux systems and 2 Windows systems). Every machine is connected to a private network that cannot see the outside world. As you might expect, the occasional “clock skew” warning would be thrown by gcc, since some of the source files had date stamps in the future. To fix this, I set out to learn about configuring NTP on a private network. As is typical of the Linux world, there was little useful documentation to be found. After gleaning little bits of information from a number of sources, I figured out how to do it, and I’m writing it down for everybody’s benefit.
Our first step is to create a ’server’ machine from which all of our other machines will get the time. In this tutorial, our master machine is a Linux box. Here’s how to set things up:
# Use the local clock server 127.127.1.0 prefer fudge 127.127.1.0 stratum 10 driftfile /var/lib/ntp/drift broadcastdelay 0.008 # Give localhost full access rights restrict 127.0.0.1 # Give machines on our network access to query us restrict 192.1.1.0 mask 255.255.255.0 nomodify notrap
You’ll want to replace the highlighted sections with the private network address range that should be allowed to query this server, along with the corresponding mask, respectively. In this example, any machine on the 192.1.1.xxx network can query the master server for time updates.
service ntpd restart/etc/init.d/xntpd restart/etc/init.d/ntp restartchkconfig ntpd onchkconfig xntpd onchkconfig ntp on# Point to our network's master time server server 192.1.1.100 restrict default ignore restrict 127.0.0.1 restrict 192.1.1.100 mask 255.255.255.255 nomodify notrap noquery driftfile /var/lib/ntp/drift
Both of the highlighted sections above should point to the master server (in this case, with an IP address of 192.1.1.100).
service ntpd stop/etc/init.d/xntpd stop/etc/init.d/ntp stopntpdate -u 192.1.1.100
Again, replace the highlighted section with the IP address of the master server. Note that you may need to do this forced update two or three times to make sure things are synchronized.
service ntpd start/etc/init.d/xntpd start/etc/init.d/ntp startchkconfig ntpd onchkconfig xntpd onchkconfig ntp onOnce you’ve set this up, all the client machines will keep their clocks synchronized with the master. If you update the master server time, the clients should follow (as long as the update isn’t larger than 1000 seconds). I believe you can even point Windows systems to the master, though I have yet to try that.