16

I came across an ntp.conf file that specifies pool directives:

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
pool 0.ubuntu.pool.ntp.org
pool 1.ubuntu.pool.ntp.org
pool 2.ubuntu.pool.ntp.org
pool 3.ubuntu.pool.ntp.org

Yet it also has server directives in the same file, which I am more familiar with.

Reading about pool, I see it is meant to be used instead of server. You should use one or the other.

However, what happens if ntp.conf has both? Does one set take precedence over the other, or will all be used?

This is on Ubuntu 14.04, ntpd is version 4.2.6p5.

user3141592
  • 263
  • 1
  • 2
  • 4

3 Answers3

10

The answer was given by mboehn. To clarify more: See the document he mentioned. Especially the last lines:

The pool scheme is configured using one or more pool commands with DNS names indicating the pool from which to draw. The pool command can be used more than once; duplicate servers are detected and discarded. In principle, it is possible to use a configuration file containing a single line pool pool.ntp.org. The NTP Pool Project offers instructions on using the pool with the server command, which is suboptimal but works with older versions of ntpd predating the pool command. With recent ntpd, consider replacing the multiple server commands in their example with a single pool command

My config is:

# Specify one or more NTP servers.
pool 0.pool.ntp.org iburst
pool 1.pool.ntp.org iburst
pool 2.pool.ntp.org iburst
pool 3.pool.ntp.org iburst

# Provide your current local time as a default should you temporarly lose Internet connectivity
server 127.127.1.0
fudge 127.127.1.0 stratum 10

I now have multiple ntp servers close to my geographic location (The Netherlands) when I check

$ ntpq -4np

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.pool.ntp.org  .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.pool.ntp.org  .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.pool.ntp.org  .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.pool.ntp.org  .POOL.          16 p    -   64    0    0.000    0.000   0.000
 127.127.1.0     .LOCL.          10 l    -   64    0    0.000    0.000   0.000
-85.255.214.66   193.190.230.66   2 u    5   64  177    6.937    1.588   1.645
-5.39.184.5      91.148.192.49    3 u   64   64   77    8.907    1.197   1.635
-91.198.87.229   193.79.237.14    2 u    5   64  177    8.447   -0.042   0.894
+37.34.57.151    193.79.237.14    2 u    1   64  177    7.463    0.168   0.297
*91.198.87.118   192.87.110.2     2 u    2   64  177    8.593    0.070   0.384
+88.159.1.197    80.94.65.10      2 u    2   64  177   10.497    0.454   0.213
+213.154.236.182 213.136.0.252    2 u   67   64   77    8.793    0.455   2.391
#178.21.23.127   91.121.157.10    3 u   66   64   77    9.129   -0.911   1.541
#213.109.127.195 193.79.237.14    2 u   66   64   77   11.766   -7.330   1.501
+213.154.229.24  80.50.231.226    2 u    4   64  177    8.496    0.121   0.538
-217.77.132.1    213.136.0.252    2 u    2   64  177    7.026   -0.782   1.253
#87.253.148.92   195.13.1.153     3 u    4   64  177    7.338   -3.859   0.964
-94.228.220.14   193.67.79.202    2 u    -   64  177    8.347    2.797   1.019
Woftor
  • 101
  • 1
  • 3
9

As far as I can see in the sources, ntpd handles both a member of a pool and individual servers roughly in the same way: it adds them to the list of peers.

All these peers are used by ntpd.

The magic of the pool mechanism is in round-robin DNS: as ntpd resolves the pool name through DNS, the response from the DNS query is a single node, which may be different every time resolution is asked.

Vincent De Baere
  • 1,783
  • 9
  • 9
  • 3
    This is mentioned in the file `discover.html` which I believe is bundled with ntpd documentation. See [the bottom](https://www.eecis.udel.edu/~mills/ntp/html/discover.html#pool) of the file – mboehn Jun 24 '15 at 20:20
  • @Vincent I downloaded source files. Can you point to exactly where I should look to verify this? – user3141592 Jun 25 '15 at 14:19
  • @mboehn In that doc and the file it references, I don't see any mention of what happens with newer versions of ntpd that support both pool and server directives when both are specified. If I'm overlooking something, please enlighten. Thanks. – user3141592 Jun 25 '15 at 14:27
  • See ntp/ntp_config.c:3776. That's where the resolution of peers from the config file happens. After, look at ntp/ntp_peer.c:554 for peer_config and ntp/ntp_peer.c:730 for new_peer. You will see that both are eventually added to the peer hash table at the end of new_peer. – Vincent De Baere Jun 25 '15 at 16:39
  • THis doesn't help someone who doesn't know what server does. Can you explain what server does so that I can compare with your last sentence of what pool does. – bakalolo Apr 12 '19 at 01:41
1

In order for NTP to properly be soliciting a pool of timeservers, and make use of the availability of timeservers in any failover scenario, ntp.conf should be configured as such:

  • declare the pool's domain name with a pool command (and not server)

  • allow the pool to mobilize an association (i.e. add a "restrict source ..." line that does not include the nopeer directive)

drgnfr
  • 41
  • 3