Configurar la hora con NTP
Hola a todos, esta semana me ha dado por configurar la hora en mi servidor con NTP para tenerla siempre actualizada.
Lo he hecho asi:
1. Instalar el paquete ntp:
apt-get install ntp2. Configurar el servicio:
$ cat /etc/ntp.conf
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
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
# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
# pick a different set every time it starts up. Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.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 more closely.
restrict 127.0.0.1
restrict ::1
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient
Como veis he puesto los servidores por defecto de Debina para el NTP.
Al ejecutar esto me dice el desfase que tiene mi servidor respecto a los otros:
$ ntpdc -p
remote local st poll reach delay offset disp
=======================================================================
=hora.rediris.es 192.168.1.3 1 64 377 0.05367 -0.002389 0.07431
*158.227.98.15 192.168.1.3 1 64 377 0.05652 -0.000720 0.05312
=ntp01.es6.egwn. 192.168.1.3 2 64 377 0.11800 -0.005681 0.05582
=gong.ci.uv.es 192.168.1.3 2 64 377 0.06615 0.000845 0.06557Lo que quiero es tener la hora de mi servidor actualizada, no quiero ser un servidor de NTP para otras maquinas.
Otra duda que tengo es si esto se ejecuta cada cierto tiempo y tengo que crear algun script para CRON. O el mismo servicio se encarga de tener al dia la hora y cambiar en mi servidor.
Veo que existe un servicio en marcha:
$ ps -e | grep ntp
6371 ? 00:00:00 ntpdPero es raro que no aparezca nada en el fichero de configuracion sobre el tiempo de actualizacion.
Muchas gracias por todo y hasta pronto.
- Inicie sesión o regístrese para enviar comentarios
- 423 lecturas


Nunca me gusto ntpd, yo instalé ntpdate y agregue a mi /etc/crontab la linea:
00 * * * * root /usr/sbin/ntpdate -t 10 pool.ntp.orgCon eso ajusto el reloj cada una hora.
Espero te sea útil:
"Cómo sincronizar la hora usando Network Time Protocol en la terminal"
http://sidd.homelinux.net/blog/index.php?post/2009/09/19/C%C3%B3mo-sincr...
Saludos,
Sidd.
Muchas gracias!
Segun veo con "ntpdate" se tiene que ejecutar manualmente (o con cron).
Pero me sigue quedando la duda de "ntp", ¿solo sincroniza en el arranque? ¿o cada cierto tiempo se sincroniza?
El servidor que tengo en casa puede estar meses sin reiniciar, si solo me actualiza al arranque no me sirve de mucho.
Seguire leyendo un poco mas.
Muchas gracias por vuestra ayuda.
Saludos y hasta pronto.
Muchas gracias!
Segun veo con "ntpdate" se tiene que ejecutar manualmente (o con cron).
Pero me sigue quedando la duda de "ntp", ¿solo sincroniza en el arranque? ¿o cada cierto tiempo se sincroniza?
El servidor que tengo en casa puede estar meses sin reiniciar, si solo me actualiza al arranque no me sirve de mucho.
Seguire leyendo un poco mas.
Muchas gracias por vuestra ayuda.
Saludos y hasta pronto.
Si te instalas ntpdate verás que en /etc/networks/if-up.d se instala el script ntpdate, es decir, cada vez que se levante la interfaz de red el equipo como por ejemplo al encenderlo intentará actualizar la hora.
En mi caso uso un script que se ejecuta cada tres horas via crontab, el script está basado en el artículo siguiente: http://www.debianadmin.com/keeping-your-system-clock-current-automatical...