我试图得到一个系统,没有外部互联网接入(A),从局域网上的另一个系统获得的时间(B)。
在A的ntp.conf (整件事情在底部)中,我添加了:
server 192.168.2.102
restrict 192.168.2.102指的是B的IP在阅读了一个小时的手册页面、查看在线示例等之后,据我所知,这意味着它将使用该本地服务器,并将其用于任何事情。
但是,它不起作用。我可以在wireshark中观看两个交换时间,并在A上运行ntpq -p显示:
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如果我在A上停止ntpd并尝试使用ntpd -gq,我可以在wireshark中来回观看一次,但一两分钟后,命令就会出现“没有找到服务器”的情况。
我甚至尝试过在A的公寓里添加:
fudge 192.168.2.102 stratum 1没什么区别。
如何强制ntpd从特定服务器设置时间?这看起来很容易使用ntpdate --它是折旧的,在系统中不存在。
这是机器A的全部ntp.conf,这是Debian股票。我所做的唯一修改就是添加涉及192.168.2.102的行,并注释掉debian池服务器,以消除那里的混乱,因此无论如何都是无法到达的。
# /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发布于 2015-01-07 21:15:12
我确实让它起作用了,所以对于后人,#ntp (freenode)上的某个人说,如果B不报告自己是同步的,那么机器A可能会不高兴。这可以用B上的ntpq -p观察到,没有显示任何以星号为前缀的服务器。
在B上伪造本地源(通过检查系统时钟来实现同步)更正如下:
server 127.127.1.0
fudge 127.127.1.0 stratum 10但是,重要的是不要在A上这样做,因为它比计算“本地同步”机器B的值更信任阶层10。
发布于 2015-01-07 19:13:42
下面这样的东西应该能起作用。
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 10https://unix.stackexchange.com/questions/177999
复制相似问题