![Utilice el servicio NTP local](https://rvso.com/image/36015/Utilice%20el%20servicio%20NTP%20local.png)
Estoy intentando conseguir que un sistema sin acceso externo a Internet (A) obtenga la hora de otro sistema en la LAN que sí lo tenga (B).
En ntp.conf de A (todo está en la parte inferior), agregué:
server 192.168.2.102
restrict 192.168.2.102
Refiriéndose a la IP de B. Después de una hora de leer páginas de manual, mirar ejemplos en línea, etc., hasta donde puedo decir, esto debería significar que usará ese servidor local y confiará en él para cualquier cosa.
Sin embargo, no funciona. Puedo ver los dos horarios de intercambio en wireshark
y en ejecución ntpq -p
en los programas A:
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.2.102 .INIT. 16 u 16 64 0 0.000 0.000 0.000
Si me detengo ntpd
en A y lo intento ntpd -gq
, puedo volver a ver un ida y vuelta en Wireshark, pero después de uno o dos minutos, el comando se agota y dice "No se encontraron servidores".
Incluso intenté agregar a la configuración de A:
fudge 192.168.2.102 stratum 1
No hace ninguna diferencia.
¿Cómo puedo forzar a ntpd a configurar la hora desde un servidor específico? Parece que esto solía ser bastante fácil de usar ntpdate
, que está depreciado y no existe en el sistema.
Aquí está el ntp.conf completo para la máquina A. Este es el archivo estándar de Debian wheezy. Los únicos cambios que hice fueron agregar las líneas que involucran 192.168.2.102 y comentar los servidores del grupo de Debian para intentar eliminar la confusión allí, por lo que de todos modos son inalcanzables.
# /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
server 192.168.2.102
restrict 192.168.2.102
fudge 192.168.2.102 stratum 1
# 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
Respuesta1
Algo como lo siguiente debería funcionar.
restrict default ignore
restrict 127.0.0.1 nomodify
restrict 192.168.2.102 mask 255.255.255.0 nomodify notrap noquery
server 192.168.2.102 burst iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 10
Respuesta2
Lo hice funcionar, por lo que para la posteridad, alguien en #ntp
(freenode) dijo que la máquina A puede no estar contenta si B no se informa como sincronizada. Esto se puede observar ntpq -p
en B, que no muestra ningún servidor con el prefijo de asterisco.
Engañándose con una fuente localB(que en realidad se sincroniza, mediante el examen del reloj del sistema) corrigió eso:
server 127.127.1.0
fudge 127.127.1.0 stratum 10
Sin embargo, es importantenohaz eso enAya que confiará en el estrato 10 más que en lo que considere la máquina B "sincronizada localmente".