如何让我的笔记本电脑在不连接互联网的情况下充当 LAN 中的 NTP 服务器?

如何让我的笔记本电脑在不连接互联网的情况下充当 LAN 中的 NTP 服务器?

我需要将我的笔记本电脑设置为我自己的局域网内的 NTP 服务器。

据我所知,我只能在以下情况下将客户端同步到局域网中的 NTP 服务器:

a.) There is an internet connection.
b.) When I tried to connect to another LAN without internet access, I still managed to sync the computer.

我连接了两个 LAN:

1.) 192.168.1.x subnet with internet
2.) 192.168.2.x subnet without internet

这是服务器。如您所见,当我在没有互联网的情况下连接到 LAN 时尝试重新启动服务时,我无法与客户端同步。

服务器

瞧,我同步失败了。但是,如果我连接到互联网,一切就都正常了。如何设置 NTP 服务器,以便即使我没有任何互联网连接,我的笔记本电脑仍然可以充当 NTP 服务器,我的 LAN 中的客户端将能够同步到该服务器?

客户

我还在这里包含了我的 /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

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information. server 0.ubuntu.pool.ntp.org server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org server 127.127.1.0 fudge 127.127.1.0 stratum 10

# Use Ubuntu's ntp server as a fallback. server ntp.ubuntu.com

# 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.1.255
#broadcast 192.168.2.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

# Allow LAN machines to synchronize with this ntp server
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
#restrict 192.168.2.0 mask 255.255.255.0 nomodify notrap

答案1

我偶然发现了一个解决办法。:-)

编辑文件 /etc/ntp.conf

#add these
server 127.127.1.0 iburst
fudge 127.127.1.0 stratum 10

并注释掉所有其他服务器。:-)

PS 我不太确定 iburst。我猜也可以不包含它。

相关内容