In association with heise online

Setting up an NTP server

If you want to set up your own time server, you should set aside a good bit of time and muster up your patience. You have to re-start the server process every time a change is made to the configuration. Once the restart is complete, ntpd needs several minutes before it can serve any clients or is able to give useful information to debugging tools. Initially, the hardware clock needs an hour before it trusts ntpd.

The first time it is called, ntpd often shuts itself down again immediately, because it only likes to run when the clock does not deviate from the reference time by more than 1,000 seconds. If this happens, either you have to add the option, -g to the program, or set the clock in advance with ntpdate.

# File /etc/ntp.conf
driftfile /etc/ntp/drift
# Time-sources
server 127.127.1.0
fudge 127.127.1.0 stratum 10
server ntp2.sandvika.net iburst
server chronos.csr.net iburst prefer
# Key for ntpdc
keys /etc/ntp/keys
trustedkey 1
requestkey 1

Ntpd reads its settings from the file called /etc/ntp.conf. With the driftfile option, you can specify a file into which ntpd puts a value to correct the system clock after every hour of runtime. This allows the program to initialise its internal control loop immediately the next time it is called without having to spend time observing the computer clock.

Each source for time synchronisation occupies its own server line in ntp.conf. In addition to the NTP servers, these can also be locally connected clocks. There are a variety of drivers included in the NTP package for various clock modules, which can be accessed using pseudo IP addresses. For example, the driver for the RTC component on the motherboard has the address, 127.127.1.0. A line that begins with fudge specifies additional options for a time source. In the example, it specifies a very high stratum for the RTC, allowing ntpd to access it only when no other NTP server is accessible.

Placing iburst after the server address speeds up the initial synchronisation since ntpd queries servers with this designation with more NTP packets than usual and is thus able to collect the data necessary to make the evaluation more quickly. The option prefer on a server line prompts ntpd to give preference to that server when several servers are judged to be equally good sources for synchronisation.

In its evaluation, ntpd sorts accessible sources according to stratum, packet runtime across the network (delay), deviation from its own clock (offset) and the distribution of the most recent offset data (jitter). The server uses the best time source according to these criteria as a reference. That is why choosing suitable servers is significant for the stable operation of your own server.

Print Version | Permalink: http://h-online.com/-747376
  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit