ローカルNTPサービスを使用する

ローカルNTPサービスを使用する

外部インターネット アクセスのないシステム (A) で、LAN 上のインターネット アクセスのある別のシステム (B) から時刻を取得しようとしています。

A の ntp.conf (全体は一番下にあります) に以下を追加しました:

server 192.168.2.102
restrict 192.168.2.102

B の IP を参照します。1 時間かけてマニュアル ページを読み、オンラインの例などを確認した結果、私の知る限り、これはそのローカル サーバーを使用し、あらゆる点でそれを信頼することを意味するはずです。

しかし、うまくいきません。 で 2 つの交換時間を確認できますwiresharkが、ntpq -pA で実行すると次のように表示されます。

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

ntpdA で停止して試してみるとntpd -gq、Wireshark で再度やり取りを観察できますが、1、2 分後にコマンドが「サーバーが見つかりません」というメッセージでタイムアウトになります。

A の conf に追加してみました:

fudge 192.168.2.102 stratum 1

違いはありません。

ntpd に特定のサーバーからの時刻を強制的に設定するにはどうすればよいですか? 以前は、これはかなり簡単に使用できたようですntpdateが、廃止され、システム上には存在しません。


マシン A の ntp.conf 全体を以下に示します。これは標準の Debian wheezy です。私が行った唯一の変更は、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

答え1

次のようなものが機能するはずです。

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

答え2

実際に動作させることができましたが、後世のために (freenode) の誰かが、マシン B が同期済みとして報告しない場合、マシン A は不愉快になる可能性があると言っていました。これは、B でアスタリスクの付いたサーバーが表示されないこと#ntpで確認できます。ntpq -p

地元の情報源を偽造するB(システム クロックを調べると、実際には同期しています) 次のように修正しました。

server 127.127.1.0
fudge  127.127.1.0 stratum 10

しかし、重要なのはないそれをする「ローカルに同期された」マシン B を何と数えるかよりも、stratum 10 を信頼するからです。

関連情報