# NTP Not Syncing Time

## Jerry Gardner

I'm running an NTP server on my Gentoo box to sync the time on the other machines on my network (one running Solaris 10 and the other Debian Sarge). 

On the Gentoo box, NTP gets its time from a public timeserver on the Internet. NTP on the other two boxes point to the Gentoo box as their server. 

After starting everything up, I see that ntpd is listening on UDP port 123 on all of the machines, but the time on the two 'slave' machines doesn't get synchronized with the 'master' even after letting them run for several days.

Is there something I forgot to configure on either the server or slaves that is causing this?

----------

## expat_iain

How are you calling ntpdate?? Do you hve it cron'd??

----------

## Jerry Gardner

I'm not using ntpdate. I'm running ntpd on all machines and expecting the slaves to synchronize to the server.

----------

## expat_iain

What do you have in /etc/ntp.conf?

----------

## Jerry Gardner

Server:

server 132.163.4.103    (time-c.timefreq.bldrdoc.gov)

Clients:

server 10.0.0.1  (this is the IP address of the server machine on the LAN)

Note: the comments above in ()'s are not actually in the config files.

----------

## nobspangle

The time will only synchronise if it is close to start with. First off you need to stop ntpd and run 

```
ntpdate 10.0.0.1
```

on both of the client machines, then make sure that there is a driftfile line in all of your ntp.conf files and make sure that the location of the drift file is writeable by the user running ntpd. Then start ntpd on all machines, the drift file should be created after around 1 hour.

I have a similar setup for the servers at work, 1 gentoo box and 1 windows nt box get time from the Internet, and all the other systems including windows, linux and solaris feed from them. They all maintain time to within 1-10ms.

A good way to tell if your machine is synchronising properly is to run.

```
ntpq -pn
```

On a box at home that syncs to one ntp server that gives me

```
     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

*192.168.69.10   130.88.203.64    3 u  435 1024  377    0.525    0.846   0.155
```

If after running the daemon for a few hours poll is at 1024 and reach is at 377 all is good. My solaris box gives a similar output but the final column is called disp instead of jitter, I don't know why.

----------

## Plaz

After fighting with NTP synchronization problems and finally getting a configuration that I'm pretty happy with, I thought I'd share some config files which seem to work pretty well for a local server/client.

Server ntp.conf

```

# Add some useful log messages to our ntpd.log file

#

logconfig       =syncevents +peerevents +sysevents +allclock

logfile         /var/log/ntpd.log

driftfile       /var/lib/ntp/ntp.drift

# Allow local clients to query this server, but not update it

#

restrict default ignore

restrict 127.0.0.1

restrict 192.168.1.0 mask 255.255.255.0 nomodify nopeer notrap

# Replace <server-#> with valid Stratum-2 server names from:

# http://ntp.isc.org/bin/view/Servers/StratumTwoTimeServers

#

server          <server-1>

server          <server-2>

server          <server-3>

restrict        <server-1>        nomodify notrap noquery

restrict        <server-2>        nomodify notrap noquery

restrict        <server-3>        nomodify notrap noquery

# Local clock is a low-priority backup in case the official

# timeservers are unavailable

#

server          127.127.1.0

fudge           127.127.1.0 stratum 10

```

Client ntp.conf:

```

# Use local time server (fix server name for your domain)

#

server ntp.mydomain.com

# Don't allow traffic from any systems except the ones

# we authorize below

#

restrict default ignore

restrict 127.0.0.1

restrict ntp.mydomain.com         nomodify notrap noquery

# Local clock is a lower-priority backup in case we can't

# communicate with the main timeserver

#

server        127.127.1.0

fudge         127.127.1.0  stratum 12

```

Of course in a real production environment, you'd probably want three local NTP servers each pointing to three different Stratum-2 servers and then all of the clients would use all of the local servers, but the configs above show some of the settings I found useful (or necessary) to get good results.

----------

## Crisis

As said above, my best guess would be that the times are not close enough to begin with.

Look for errors on the client machine regarding time being out of bounds.

----------

