Tabla de Contenidos
instalación
En ubuntu sólo hay que instalar dos paquetes (en general se instalan por default):
sudo apt-get install ntp ntpdate
standalone system
La configuración mínima para un sistema standalone se puede usar tal cual viene en el paquete ntp de ubuntu. Yo en general prefiero cambiar el servidor que viene por default (ntp.ubuntu.com) por un conjunto de servidores de pool.ntp.org. Además, la gente de ntp.org recomienda usar la opción iburst en las líneas de server, con lo cual, en lugar de:
# You do need to talk to an NTP server or two (or three). server ntp.ubuntu.com
que es lo que viene por default se puede poner:
server 0.pool.ntp.org iburst server 1.pool.ntp.org iburst server 2.pool.ntp.org iburst server 3.pool.ntp.org iburst
pool.ntp.org también tiene agrupaciones regionales y por país, con lo cual, en Sur América se puede usar:
server 0.south-america.pool.ntp.org iburst server 1.south-america.pool.ntp.org iburst server 2.south-america.pool.ntp.org iburst server 3.south-america.pool.ntp.org iburst
o en Argentina:
server 0.ar.pool.ntp.org iburst server 1.ar.pool.ntp.org iburst server 2.ar.pool.ntp.org iburst server 3.ar.pool.ntp.org iburst
Una configuración minimalista para un equipo standalone podría ser:
driftfile /var/lib/ntp/ntp.drift server 0.ar.pool.ntp.org iburst server 1.ar.pool.ntp.org iburst server 2.ar.pool.ntp.org iburst server 3.ar.pool.ntp.org iburst # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> # might also be helpful. # # Note that "restrict" applies to both servers and clients, so a configuration # that might be intended to block requests from certain clients could also end # up blocking replies from your own upstream servers. # By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery # Local users may interrogate the ntp server restrict 127.0.0.1 restrict -6 ::1
Configuración en una red local
Yo tenía la idea de configurar un server local que se configure como cliente de los servidores públicos y a su vez permita que el resto de los equipos de la LAN le soliciten el servicio a este. Sin embargo, se recomienda usar más de un servidor local.
Lo mejor en estos casos es que todos los servidores locales tengan la misma configuración entre sí y todos los clientes también tengan la misma configuración entre sí. Los servidores locales se tienen entre ellos como peers de modo de intercambiar información y estar sincronizados entre sí.
Supongamos que usamos tres equipos en la red como servidores para el resto. Pongámosles los siguientes nombres (usar el dominio que corresponda)
- ntp0.example.net
- ntp1.example.net
- ntp2.example.net
La red local es 10.20.30.0/24 (desde esta red se podrá interrogar a los servers)
La estación de trabajo del administrador de la red está en 10.20.30.40 (le vamos a dar permiso para interrogar y modificar los servers desde su estación de trabajo)
Configuración de los servers
Los tres servers llevan la misma configuración:
# drift file driftfile /var/lib/ntp/ntp.drift # servers server 0.ar.pool.ntp.org iburst server 1.ar.pool.ntp.org iburst server 2.ar.pool.ntp.org iburst server 3.ar.pool.ntp.org iburst # peers (including self) peer ntp0.example.net peer ntp1.example.net peer ntp2.example.net # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> # might also be helpful. # # Note that "restrict" applies to both servers and clients, so a configuration # that might be intended to block requests from certain clients could also end # up blocking replies from your own upstream servers. # By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery # Local users may manage the ntp server restrict 127.0.0.1 restrict -6 ::1 # Administrator workstation can also manage the ntp server restrict 10.20.30.40 # Local network can ask for time and interrogate the server, but can't modify its config or time restrict 10.20.30.0 255.255.255.0 kod nomodify notrap nopeer
Configuración de los clientes
# drift file driftfile /var/lib/ntp/ntp.drift # local servers server ntp0.example.net iburst server ntp1.example.net iburst server ntp2.example.net iburst # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> # might also be helpful. # # Note that "restrict" applies to both servers and clients, so a configuration # that might be intended to block requests from certain clients could also end # up blocking replies from your own upstream servers. # By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery # Local users may manage the ntp server restrict 127.0.0.1 restrict -6 ::1 # Administrator workstation can also manage the ntp server restrict 10.20.30.40
Puesta en hora inicial y arranque
En general conviene inicializar el reloj interno de la máquina con los de los servidores a mano y después iniciar el servicio:
NTPSERVERS=`grep '^server ' /etc/ntp.conf | cut -d ' ' -f 2`
sudo invoke-rc.d ntp stop
echo "Sincronización manual usando servidores: ${NTPSERVERS}"
if sudo ntpdate ${NTPSERVERS} ; then
echo "OK"
else
echo "FALLÓ ntpdate"
fi
sudo invoke-rc.d ntp start
.