View this PageEdit this PageUploads to this PageVersions of this PageHomeRecent ChangesSearchHelp Guide

Cómo configurar un servidor NTP (y sus clientes) en Linux

Poner un servidor de NTP en una red usando debian


Si el servidor no tiene conexión a internet
Según este mensaje, la única manera de poner un servidor "aislado" es usando el chrony (por mucho que en las lista del ntpd digan lo contrario, resulta que en el ntpd es código sin probar...).

Procedimiento:
  1. Instalar el chrony:
    # apt-get install chrony
  2. Configurar la red a la que se quiere dar servicio (p.ej. a la 12.x.x.x):
    # sed -i "/^allow 10.8/iallow 12/8" /etc/chrony/chrony.conf
  3. Rearrancar el servidor
    # /etc/init.d/chrony restart


Si el servidor tiene conexión a internet
En el servidor hay que instalar ntp-simple, sin poner nada en el /etc/ntp.conf

En los clientes hay que instalarlo también, pero esta vez sí que hay que configurar el /etc/ntp.conf, tal y como se explica abajo (pero poniendo el hostname del servidor que has configurado en vez del que ahí dicen).

Set up a time server for clients on a LAN
(taken from google cache of a page in bryanconsulting.com)

For the servers that sync with the outside, put these two lines in your /etc/ntp.conf (the other lines in the file are probably correct and should be left alone):

 server ntp-0.cso.uiuc.edu 
 server ntp-1.mcs.anl.gov 

You can get a list of public NTP (stratum 2 or 3) servers at http://www.eecis.udel.edu/~mills/ntp/clock2.htm. People report excellent results with tick.usno.navy.mil and tock.usno.navy.mil, but you really shouldn't use those, since they're stratum 1 servers.

When you're done, the server has this in its
/etc/ntp.conf:

server ntp2.cs.wisc.edu
server ntp-1.cso.uiuc.edu

driftfile /etc/ntp/drift

Before we start the NTP daemon, run ntpdate from the command line to set the initial date and time, otherwise it will take forever for the daemon to get the clock set to the correct time. Of course, if you have something time-sensitive running on your computer, be careful.

Then just start NTP:

 /etc/init.d/ntp restart 

On the clients, change the server lines in /etc/ntp.conf to point to your new (level 3) servers and start NTP on them.

The ntpdc utility will come in handy to make sure that the daemon is communicating with your upstream time servers. Within ntpdc, the monlist command will give a list of hosts and stats.

For any other questions, head over to the main source of NTP info at http://www.ntp.org/ or check out http://www.eecis.udel.edu/~ntp/documentation.html

Muy importante: quitar el nopeer del /etc/ntp.conf


Según esta página, la única cosa importante si se es servidor, es quitar de las líneas donde aparezca la palabra clave "nopeer".

Notas sobre las pruebas realizadas entre frontml03 y pboadilla:



Monday, 18 June 2007, 6:30:14 pm
Al final la solución pasaba por usar el chrony Y es la única solución, por lo que parece, ya que con el chrony sí hay informes de éxito, mientras que con el ntpd sólo hay preguntas (y nadie informa que haya conseguido ponerlo).

Monday, 18 June 2007, 5:51:32 pm
LocalRefClocks Este mensaje pregunta justo lo que necesitamos, y la respuesta es que configures un LocalRefclocks. A ver qué tal. Porque ya he configurado el modo orphan y no parece que vaya muy bien...
In the default mode the behavior of the clock selection algorithm is modified when this driver is in use. The algorithm is designed so that this driver will never be selected unless no other discipline source is available. This can be overridden with the prefer keyword of the server configuration command, in which case only this driver will be selected for synchronization and all other discipline sources will be ignored. This behavior is intended for use when an external discipline source controls the system clock. See the Mitigation Rules and the prefer Keyword page for a detailed description of the exact behavior.



Wednesday, 6 June 2007, 7:26:57 pm
Orphan mode sample configuration En este post:
This is a working minimal broadcast configuration for participants in an
orphan group (orphange?) on the 192.168.0.0/24 network:

"client" /etc/ntp.conf:

driftfile /var/lib/ntp/ntp.drift
keys /etc/ntp.keys
trustedkey 1
tos orphan 5
broadcastclient
broadcast 192.168.0.255 key 1


"server" /etc/ntp.conf:

driftfile /var/lib/ntp/ntp.drift
keys /etc/ntp.keys
trustedkey 1
tos orphan 5
broadcastclient
broadcast 192.168.0.255 key 1
server pool.ntp.org iburst
server pool.ntp.org iburst
server pool.ntp.org iburst
server pool.ntp.org iburst


/etc/ntp.keys:

1 M password




Tuesday, 5 June 2007, 7:38:51 pm
Importante: "tos orphan stratum" Ver este post.

Tuesday, 5 June 2007, 7:26:55 pm
Alternativa: usar el chrony en vez del ntp

Tuesday, 5 June 2007, 7:26:39 pm
Hacer que Debian no toque el reloj hardware Se hace con lo siguiente:
/etc/default/rcS
HWCLOCKACCESS=no


Tuesday, 5 June 2007, 7:05:17 pm
Intentando instalar el NTP en frontml02/03 Según este mensaje, hay que tener instalado ntp ntp-simple ntpdate. Los instalo con:
# dpkg -i /var/cache/apt/archives/ntp_4.2.2.p4+dfsg-2_i386.deb /var/cache/apt/archives/ntpdate_4.2.2.p4+dfsg-2_i386.deb /var/cache/apt/archives/ntp-simple_4.2.2.p4+dfsg-2_all.deb