我正在尝试设置我的 Debian 6 (Squeeze) VM 作为我的网络的本地时间服务器。我已将其设置为与tock.usno.navy.mil
1 层服务器同步。
我在查找有关如何设置 ntp 守护进程以向请求时间的客户端提供时间的信息时遇到了一些问题。我查看了 ntpd 手册页,这可能是我找到的最好的文档。支持网站对我来说几乎没用,我发现的文档更多地谈论 NTP 如何工作而不是如何配置服务器。
我还注意到我的日志中没有收到任何有关与列出的服务器同步的信息。
任何人能提供的帮助都非常好,我不确定哪里出了问题。我确定这是我在做的事情。我之前有一个时间服务器在运行,但我的 SAN 崩溃了,而且我没有做备份,因为它是用于测试。所以我没有旧配置可以查看。
这是一份副本,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 tock.usno.navy.mil 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
restrict 10.0.0.0 mask 255.255.255.0 notrap nomodify
# 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
以下是ntpq -p
root@ns01:/home/ns01# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
ntp1.usno.navy. .USNO. 1 u 43 64 1 34.747 -2891.0 1669.51
iptables 的输出
Output from `iptables -L -n -v`
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
更新
当我从配置中删除这行时,restrict 10.0.0.0 mask 255.255.255.0 notrap nomodify
ntp 似乎恢复了活力。这是我现在看到的内容ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
-barricade.rack9 209.51.161.238 2 u 39 64 377 37.887 -2977.7 3.180
*gallifrey.chpc. 92.113.67.127 2 u 26 64 377 68.155 -2969.0 3.024
+clock.trit.net 204.34.198.41 2 u 2 64 377 83.146 -2972.0 3.756
+ntp1.Housing.Be 169.229.128.214 3 u 63 64 377 105.803 -2972.6 2.698
测试桌面 ifconfig 输出(MadHatter 请求)
eth0 Link encap:Ethernet HWaddr 08:00:27:59:2d:3a
inet addr:10.0.0.21 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe59:2d3a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:62103 errors:0 dropped:0 overruns:0 frame:0
TX packets:51822 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10339609 (9.8 MiB) TX bytes:7249927 (6.9 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:56 errors:0 dropped:0 overruns:0 frame:0
TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5066 (4.9 KiB) TX bytes:5066 (4.9 KiB)
答案1
您需要确保从 LAN 到服务器的 udp 端口 123 是开放的,并且从服务器返回到 LAN 也是开放的。
此外,您还可以通过运行以下命令检查服务器同步的状态
“ntpq-p”
我建议在您的配置中添加至少三个上游服务器。
尝试通过“ntpdate servername”将您的一个客户端指向您的服务器,看看会发生什么。