# ntp error

## RayS

I emerged ntp  4.2.0.20040617-r3

I am using the default  /etc/ntp.conf  file

when I run /etc/init.d/ntpd start  the system tells me that ntpd has started

but I get the following error in /var/log/messages     

```
 Listening on interface wildcard, 0.0.0.0#123

 Listening on interface lo, 127.0.0.1#123

 Listening on interface eth0, 172.16.16.104#123

 kernel time sync status 0040
```

If I check the open ports  port 123 is not listening.

If I run ntpdate manually it works fine.

any ideas what is wrong ?

thank you

Ray

----------

## PaulBredbury

Follow the wiki.

----------

## RayS

Soryy I should have said I followed the wiki  HowTo_NTP

I skipped the part on  setting up ntpdate because I want to use ntpd

I   sync the hw clock at shutdown.

----------

## PaulBredbury

Most of the threads about ntp failing, are caused by users thinking they know better than the wiki, when they've never set up ntp before  :Confused: 

The wiki entry contains a troubleshooting section - read and do what it says about "ntpq".

----------

## RayS

I have done a fresh installation and followed the wiki step by step. 

I still get the  kernel status 0040.

the output from  ntpq -c pe 

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

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

*ntp3.usv.ro     .GPS.            1 u   55   64   77  550.651   41.798  51.373

+banana.irc.gr   131.188.3.220    2 u   52   64   77  548.249   34.228  42.280

+ntp1.chorus.net .GPS.            1 u   49   64   77  421.373   34.739  20.499
```

the output from ntpq -c rv | grep stratum

```
processor="i686", system="Linux/2.6.12-gentoo-r6", leap=11, stratum=16,
```

I have obviously done something wrong . I have been through the wiki about 10 times.

any ideas

Thank's

----------

## PaulBredbury

See this thread - try:

```
/etc/init.d/ntpd stop

rm /var/lib/ntp/ntp.drift

/etc/init.d/ntpd start
```

Also, check that your "restrict" lines don't contain additional entries.

----------

## RayS

Hi 

I have been trying to find my problem. I seem to have made some progress. But I still cannot sink to the

serve from a workstation.

My /etc/ntp.conf

 *Quote:*   

> 
> 
> restrict 127.0.0.1 nomodify
> 
> # Allow ntp to automatically correct predictable clock drift
> ...

 

My  /var/log/ntp.log  after running for a few hours. Do you know where I can get more details on the sync codes ? and why

it takes about one hour to get sync enabled ? I ran ntpdate  before starting ntpd manually.

 *Quote:*   

> 
> 
> 21 Jan 14:13:44 ntpd[27455]: synchronized to 212.13.207.101, stratum 2
> 
> 21 Jan 14:14:33 ntpd[27455]: ntpd exiting on signal 15
> ...

 

output from   ntpq -c pe

 *Quote:*   

> 
> 
>      remote           refid      st t when poll reach   delay   offset  jitter
> 
> ==============================================================================
> ...

 

output from ntpq -c rv | grep stratum

 *Quote:*   

> 
> 
> processor="i686", system="Linux/2.6.12-gentoo-r6", leap=00, stratum=3,
> 
> 

 

If I check the open ports on this box with nmap 

 *Quote:*   

> 
> 
> PORT    STATE SERVICE
> 
> 22/tcp  open  ssh
> ...

 

For some reason port  37 is not open . I checked /etc/sevices and the port is in the list.

Thank's again 

Ray

----------

## erikm

 *RayS wrote:*   

> 
> 
> ...
> 
>  *Quote:*   
> ...

 

Here's a problem: Ntpd by default runs as user 'ntp' in group 'ntp'. It doesn't have rw permissions on /var/. Solution:

```
# touch /var/lib/ntp/ntp.drift /var/lib/ntp/ntp.drift.TEMP && chown ntp:ntp /var/lib/ntp/ntp.drift* && /etc/init.d/ntpd restart
```

Ntp makes very small incremental adjustments to your system clock to achieve the best possible sync. Thus, it needs a lot of statistics before it can sync properly - that is, an hour to sync is not out of the ordinary. 

Finally, a little oddity I ran into with ntpq:

```
# ntpq -p
```

won't work properly if your /etc/hosts file doesn't contain a line of the format

```
127.0.0.1 <hostname>@<domainname> <hostname> localhost
```

Note the 'localhost' entry.

Good luck.

----------

## RayS

Hi 

Thanks for the input .

I still do not have port 37 open. So I cannot sink the pc's on the lan to the server

any ideas ?

Thank's

Ray

----------

## RayS

OK  It is working thank you for the help.  Most of the problems was me not understanding ntp,  well thats how you

learn.  I can now sync my linux pc to the server using ntpdate. 

I still have a question though . I have a Debian sarge server running ntpd  and I can sync the windows pc's connecting to

port 37 (TCP/UDP)  or to port 123 using sntp.  On the Gentoo server  I must use sntp on port 123.   What do the Debian team do 

differently from Gentoo ?

Thank's again it was a struggle but at least I learnt a little.

Ray

----------

