# ntpd not work

## pigreco

Hi,

hi have a issue with ntpd service on my server, I want a Time Server for sincronize all my others servers; the problem is that ntpd daemon non reach peers.

I have checked firewall many time and is ok, furthermore stopping the firewall not changhe the situation, the port 123 for udp is open

```
sudo nmap -sU -P0 -p 123 etaromdue.etarom.com 

Starting Nmap 6.46 ( http://nmap.org ) at 2014-10-31 15:08 CET

Nmap scan report for etaromdue.etarom.com (77.72.24.73)

Host is up (0.062s latency).

PORT    STATE SERVICE

123/udp open  ntp

Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds

```

but ntpd not reach, in debug mode I have see only transmission log but not receptions, so:

```
ntpq -pn 127.0.0.1

     remote           refid      st t when poll reach   delay   offset  jitter

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

 194.116.87.4    .INIT.          16 u    -  256    0    0.000    0.000   0.000

 62.48.53.90     .INIT.          16 u    -  256    0    0.000    0.000   0.000

 212.45.144.16   .INIT.          16 u    -  256    0    0.000    0.000   0.000

 72.52.4.121     .INIT.          16 u    -  256    0    0.000    0.000   0.000

 84.201.30.243   .INIT.          16 u    -  256    0    0.000    0.000   0.000

 120.88.46.10    .INIT.          16 u    -  128    0    0.000    0.000   0.000

 113.30.137.34   .INIT.          16 u    -  128    0    0.000    0.000   0.000

 202.71.140.36   .INIT.          16 u    -  128    0    0.000    0.000   0.000

 123.108.225.6   .INIT.          16 u    -  128    0    0.000    0.000   0.000

*127.127.1.0     .LOCL.          10 l   23   64  377    0.000    0.000   0.000
```

ntpdate work

```
ntpdate -d -u -v 2.it.pool.ntp.org

31 Oct 15:06:37 ntpdate[17314]: ntpdate 4.2.6p5@1.2349-o Fri Oct 31 13:42:24 UTC 2014 (1)

Looking for host 2.it.pool.ntp.org and service ntp

host found : gw-ge.esaote.com

transmit(83.103.98.242)

receive(83.103.98.242)

transmit(93.62.188.182)

receive(93.62.188.182)

transmit(212.45.144.3)

receive(212.45.144.3)

transmit(83.103.98.242)

receive(83.103.98.242)

transmit(93.62.188.182)

receive(93.62.188.182)

transmit(212.45.144.3)

receive(212.45.144.3)

transmit(83.103.98.242)

receive(83.103.98.242)

transmit(93.62.188.182)

receive(93.62.188.182)

transmit(212.45.144.3)

receive(212.45.144.3)

transmit(83.103.98.242)

receive(83.103.98.242)

transmit(93.62.188.182)

receive(93.62.188.182)

transmit(212.45.144.3)

receive(212.45.144.3)

server 83.103.98.242, port 123

stratum 3, precision -18, leap 00, trust 000

refid [83.103.98.242], delay 0.10535, dispersion 0.00053

transmitted 4, in filter 4

reference time:    d7fe1600.a7a8fc10  Fri, Oct 31 2014 15:06:56.654

originate timestamp: d7fe1609.e79d21fa  Fri, Oct 31 2014 15:07:05.904

transmit timestamp:  d7fe15f3.8a05029e  Fri, Oct 31 2014 15:06:43.539

filter delay:  0.10535  0.10818  0.10547  0.11256 

         0.00000  0.00000  0.00000  0.00000 

filter offset: 22.32228 22.32066 22.32204 22.32206

         0.000000 0.000000 0.000000 0.000000

delay 0.10535, dispersion 0.00053

offset 22.322284

server 93.62.188.182, port 123

stratum 2, precision -20, leap 00, trust 000

refid [93.62.188.182], delay 0.05470, dispersion 0.00002

transmitted 4, in filter 4

reference time:    d7fe0e5a.ec2b6228  Fri, Oct 31 2014 14:34:18.922

originate timestamp: d7fe160a.0d03a1cc  Fri, Oct 31 2014 15:07:06.050

transmit timestamp:  d7fe15f3.bd38559c  Fri, Oct 31 2014 15:06:43.739

filter delay:  0.05479  0.05487  0.05470  0.05478 

         0.00000  0.00000  0.00000  0.00000 

filter offset: 22.29717 22.29719 22.29714 22.29710

         0.000000 0.000000 0.000000 0.000000

delay 0.05470, dispersion 0.00002

offset 22.297142

server 212.45.144.3, port 123

stratum 2, precision -20, leap 00, trust 000

refid [212.45.144.3], delay 0.04109, dispersion 0.00063

transmitted 4, in filter 4

reference time:    d7fe0e3b.8e2578d8  Fri, Oct 31 2014 14:33:47.555

originate timestamp: d7fe160a.3fe771b2  Fri, Oct 31 2014 15:07:06.249

transmit timestamp:  d7fe15f3.f06b6a0e  Fri, Oct 31 2014 15:06:43.939

filter delay:  0.04117  0.04126  0.04109  0.04887 

         0.00000  0.00000  0.00000  0.00000 

filter offset: 22.29480 22.29482 22.29466 22.29880

         0.000000 0.000000 0.000000 0.000000

delay 0.04109, dispersion 0.00063

offset 22.294662

31 Oct 15:06:43 ntpdate[17314]: step time server 212.45.144.3 offset 22.294662 sec
```

I have changed /etc/ntp.conf many times uselessly now it is:

```
cat /etc/ntp.conf 

# NOTES:

# DHCP clients can append or replace NTP configuration files.

# You should consult your DHCP client documentation about its

# default behaviour and how to change it.

disable monitor

logconfig =all

logfile /var/log/ntp

statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats

filegen loopstats file loopstats type day enable

filegen peerstats file peerstats type day enable

filegen clockstats file clockstats type day enable

# To deny other machines from changing the

# configuration but allow localhost:

#restrict default limited kod nomodify notrap nopeer noquery

restrict default limited nomodify notrap nopeer kod noquery

restrict 127.0.0.1

# Un-comment the next line, to act as a time server to the local network

restrict 192.168.1.1 mask 255.255.255.0 nomodify nopeer notrap 

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap nopeer

# Name of the servers ntpd should sync with

# Please respect the access policy as stated by the responsible person.

#server      ntp.example.tld      iburst

server -4 2.it.pool.ntp.org iburst

#restrict 2.it.pool.ntp.org

server -4 ntp.prato.linux.it iburst

#restrict ntp.prato.linux.it nomodify notrap nopeer noquery

server -4 0.pool.ntp.org iburst 

#restrict 0.pool.ntp.org nomodify notrap nopeer noquery

server -4 ntp.ionn.net iburst

#restrict ntp.ionn.net nomodify notrap nopeer noquery

server ntp5.berlin-provider.de iburst

#restrict ntp5.berlin-provider.de nomodify notrap nopeer noquery

server -4 0.in.pool.ntp.org

server -4 1.in.pool.ntp.org

server -4 2.in.pool.ntp.org

server -4 3.in.pool.ntp.org

server 127.127.1.0

fudge  127.127.1.0 stratum 10

#server ntplocal.example.com prefer 

#server timeserver.example.org 

# Warning: Using default NTP settings will leave your NTP

# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)

# from accessing the NTP server, uncomment:

#restrict default ignore

# To allow machines within your network to synchronize

# their clocks with your server, but ensure they are

# not allowed to configure the server or used as peers

# to synchronize against, uncomment this line.

#

#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap

 # Allow ntp to automatically correct predictable clock drift

 driftfile /var/lib/ntp/ntp.drift

```

I have spend many time to investigate but I can't understand where is the problem,

any suggestion is appreciated, regards

Maurizio

----------

## DONAHUE

suggest clean up the intended local time server with 

```
rm /etc/ntp.conf

emerge ntp
```

and verify that it can contact the gentoo time servers with 

```
rc-update add ntpd default

/etc/init.d/ntpd restart 

/etc/init.d/ntp-client restart
```

 once the local time server is updating itself properly from the gentoo servers use https://wiki.gentoo.org/wiki/Ntp as a guide in choosing other internet time servers if you wish to do so. test that, then configure your local server to respond to requests from local clients. then configure local clients to use the local server.

----------

## pigreco

hi, thanks for reply

ok, I get it, you tell me to try a clean install

I have removed ntp.conf e reinstalled the package, now the configuration is default:

```
cat /etc/ntp.conf

# NOTES:

# DHCP clients can append or replace NTP configuration files.

# You should consult your DHCP client documentation about its

# default behaviour and how to change it.

# Name of the servers ntpd should sync with

# Please respect the access policy as stated by the responsible person.

#server      ntp.example.tld      iburst

# Common pool for random people

#server pool.ntp.org

# Pools for Gentoo users

server 0.gentoo.pool.ntp.org

server 1.gentoo.pool.ntp.org

server 2.gentoo.pool.ntp.org

server 3.gentoo.pool.ntp.org

##

# A list of available servers can be found here:

# http://www.pool.ntp.org/

# http://www.pool.ntp.org/#use

# A good way to get servers for your machine is:

# netselect -s 3 pool.ntp.org

##

# you should not need to modify the following paths

driftfile   /var/lib/ntp/ntp.drift

#server ntplocal.example.com prefer 

#server timeserver.example.org 

# Warning: Using default NTP settings will leave your NTP

# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)

# from accessing the NTP server, uncomment:

#restrict default ignore

# Default configuration:

# - Allow only time queries, at a limited rate, sending KoD when in excess.

# - Allow all local queries (IPv4, IPv6)

restrict default nomodify nopeer noquery limited kod

restrict 127.0.0.1

restrict [::1]

# To allow machines within your network to synchronize

# their clocks with your server, but ensure they are

# not allowed to configure the server or used as peers

# to synchronize against, uncomment this line.

#

#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap

```

the behavior not change, in debug mode:

 *Quote:*   

> ntpd 4.2.6p5@1.2349-o Mon Nov  3 08:59:27 UTC 2014 (1)
> 
>  3 Nov 10:09:59 ntpd[2474]: proto: precision = 0.400 usec
> 
> event at 0 0.0.0.0 c01d 0d kern kernel time sync enabled
> ...

 

```

ntpq -pn

     remote           refid      st t when poll reach   delay   offset  jitter

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

 84.38.50.20     .INIT.          16 u    -   64    0    0.000    0.000   0.000

 194.116.87.4    .INIT.          16 u    -   64    0    0.000    0.000   0.000

 212.45.144.88   .INIT.          16 u    -   64    0    0.000    0.000   0.000

 37.247.50.70    .INIT.          16 u    -   64    0    0.000    0.000   0.000

```

the ntpd server not receive and not reach peers, but btp-client still work well through the port 123

```

ntpdate -d -u -v 2.it.pool.ntp.org

 3 Nov 10:18:58 ntpdate[3194]: ntpdate 4.2.6p5@1.2349-o Mon Nov  3 08:59:28 UTC 2014 (1)

Looking for host 2.it.pool.ntp.org and service ntp

host found : tucano.isti.cnr.it

transmit(146.48.81.102)

receive(146.48.81.102)

transmit(212.45.144.88)

receive(212.45.144.88)

transmit(212.121.88.250)

receive(212.121.88.250)

transmit(146.48.81.102)

receive(146.48.81.102)

transmit(212.45.144.88)

receive(212.45.144.88)

transmit(212.121.88.250)

receive(212.121.88.250)

transmit(146.48.81.102)

receive(146.48.81.102)

transmit(212.45.144.88)

receive(212.45.144.88)

transmit(212.121.88.250)

receive(212.121.88.250)

transmit(146.48.81.102)

receive(146.48.81.102)

transmit(212.45.144.88)

receive(212.45.144.88)

transmit(212.121.88.250)

receive(212.121.88.250)

server 146.48.81.102, port 123

stratum 2, precision -22, leap 00, trust 000

refid [146.48.81.102], delay 0.04733, dispersion 0.00008

transmitted 4, in filter 4

reference time:    d801c559.9d37cacd  Mon, Nov  3 2014 10:11:53.614

originate timestamp: d801c708.c4e91aa6  Mon, Nov  3 2014 10:19:04.769

transmit timestamp:  d801c708.c1e8c6ca  Mon, Nov  3 2014 10:19:04.757

filter delay:  0.04851  0.04733  0.04767  0.04753 

         0.00000  0.00000  0.00000  0.00000 

filter offset: 0.001236 0.000821 0.000848 0.000744

         0.000000 0.000000 0.000000 0.000000

delay 0.04733, dispersion 0.00008

offset 0.000821

server 212.45.144.88, port 123

stratum 2, precision -19, leap 00, trust 000

refid [212.45.144.88], delay 0.04108, dispersion 0.00070

transmitted 4, in filter 4

reference time:    d801bfb4.bfb217a3  Mon, Nov  3 2014  9:47:48.748

originate timestamp: d801c708.f7542061  Mon, Nov  3 2014 10:19:04.966

transmit timestamp:  d801c708.f51be89c  Mon, Nov  3 2014 10:19:04.957

filter delay:  0.04361  0.04477  0.04108  0.04166 

         0.00000  0.00000  0.00000  0.00000 

filter offset: 0.001596 0.002033 0.000263 0.000613

         0.000000 0.000000 0.000000 0.000000

delay 0.04108, dispersion 0.00070

offset 0.000263

server 212.121.88.250, port 123

stratum 3, precision -20, leap 00, trust 000

refid [212.121.88.250], delay 0.04106, dispersion 0.00050

transmitted 4, in filter 4

reference time:    d801c4ea.46631158  Mon, Nov  3 2014 10:10:02.274

originate timestamp: d801c709.2ad0dd69  Mon, Nov  3 2014 10:19:05.167

transmit timestamp:  d801c709.284f1db9  Mon, Nov  3 2014 10:19:05.157

filter delay:  0.04602  0.04239  0.04123  0.04106 

         0.00000  0.00000  0.00000  0.00000 

filter offset: 0.004312 0.002646 0.002241 0.002046

         0.000000 0.000000 0.000000 0.000000

delay 0.04106, dispersion 0.00050

offset 0.002046

 3 Nov 10:19:05 ntpdate[3194]: adjust time server 212.45.144.88 offset 0.000263 sec
```

----------

## gerdesj

Where to start  :Cool: 

You have several external IP addresses on this system so be careful with using the default config - it is designed for a system behind a NAT router and not the router itself.

Please post the output from:

#ip r

#ip a

#cat /etc/resolv.conf

Restart ntpd whilst this is running in a terminal:

#tcpdump -i eth0 "udp and port 123"

Change eth0 in the above to the external interface if I have got your logs wrong.

You have a sit0 interface - shut it down and restart ntpd and see if that helps.

You have the same version of ntpd as I do and it works flawlessly on my laptop despite hibernation, sleeping and changing networks, sometimes on wifi and sometimes on ethernet  We will get to the bottom of the problem eventually.

Cheers

Jon

----------

## pigreco

hi, thanks for reply

I had to change the server for hardware issues, so I have a different ip

```
~ # ip r 

default via 77.72.24.65 dev eth1  metric 3 

77.72.24.64/27 dev eth1  proto kernel  scope link  src 77.72.24.78 

127.0.0.0/8 dev lo  scope host 

127.0.0.0/8 via 127.0.0.1 dev lo 

192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.20 

```

```
 ~ # ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo

       valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 00:13:72:5a:03:aa brd ff:ff:ff:ff:ff:ff

    inet 192.168.1.20/24 brd 192.168.1.255 scope global eth0

       valid_lft forever preferred_lft forever

    inet6 fe80::213:72ff:fe5a:3aa/64 scope link 

       valid_lft forever preferred_lft forever

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 00:13:72:5a:03:ab brd ff:ff:ff:ff:ff:ff

    inet 77.72.24.78/27 brd 77.72.24.95 scope global eth1

       valid_lft forever preferred_lft forever

    inet6 fe80::213:72ff:fe5a:3ab/64 scope link 

       valid_lft forever preferred_lft forever
```

```
~ # cat /etc/resolv.dnsmasq

# Generated by net-scripts for interface eth0

nameserver 77.72.24.233

nameserver 77.72.24.234

nameserver 208.67.222.222

nameserver 208.67.220.220

nameserver 195.186.1.11
```

```
~ # tcpdump -i eth1 "udp and port 123" 

error : ret -1

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes

10:06:44.626469 IP etaromcinque.etarom.com.ntp > terminus.develer.net.ntp: NTPv4, Client, length 48

10:06:45.626413 IP etaromcinque.etarom.com.ntp > 93-62-184-77.ip23.fastwebnet.it.ntp: NTPv4, Client, length 48

10:06:46.626421 IP etaromcinque.etarom.com.ntp > ntp.ngi.it.ntp: NTPv4, Client, length 48

10:06:47.626428 IP etaromcinque.etarom.com.ntp > gate.evil.systems.ntp: NTPv4, Client, length 48

10:07:50.626414 IP etaromcinque.etarom.com.ntp > terminus.develer.net.ntp: NTPv4, Client, length 48

10:07:51.626401 IP etaromcinque.etarom.com.ntp > 93-62-184-77.ip23.fastwebnet.it.ntp: NTPv4, Client, length 48

10:07:52.626405 IP etaromcinque.etarom.com.ntp > ntp.ngi.it.ntp: NTPv4, Client, length 48

10:07:54.626406 IP etaromcinque.etarom.com.ntp > gate.evil.systems.ntp: NTPv4, Client, length 48

10:08:54.626378 IP etaromcinque.etarom.com.ntp > terminus.develer.net.ntp: NTPv4, Client, length 48

10:08:55.626385 IP etaromcinque.etarom.com.ntp > 93-62-184-77.ip23.fastwebnet.it.ntp: NTPv4, Client, length 48

10:08:56.626387 IP etaromcinque.etarom.com.ntp > ntp.ngi.it.ntp: NTPv4, Client, length 48

10:09:01.626374 IP etaromcinque.etarom.com.ntp > gate.evil.systems.ntp: NTPv4, Client, length 48

10:09:59.626381 IP etaromcinque.etarom.com.ntp > terminus.develer.net.ntp: NTPv4, Client, length 48

10:10:00.626388 IP etaromcinque.etarom.com.ntp > 93-62-184-77.ip23.fastwebnet.it.ntp: NTPv4, Client, length 48

10:10:03.626377 IP etaromcinque.etarom.com.ntp > ntp.ngi.it.ntp: NTPv4, Client, length 48

10:10:06.626371 IP etaromcinque.etarom.com.ntp > gate.evil.systems.ntp: NTPv4, Client, length 48
```

firewall check from my office

```
~ $ sudo nmap -sU -P0 -p 123 etaromcinque.etarom.com 

Starting Nmap 6.46 ( http://nmap.org ) at 2014-11-19 10:12 CET

Nmap scan report for etaromcinque.etarom.com (77.72.24.78)

Host is up (0.031s latency).

PORT    STATE SERVICE

123/udp open  ntp

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
```

----------

