環境 KVM
ホストOS:Debian GNU/Linux 10.7
ゲストOS:FreeBSD 12.2-RELEASE r366954 GENERIC amd64
ゲストOS:Debian GNU/Linux 10.7
ゲストOSのFreeBSDに、NTPサーバを構築してLAN内のマシンと同期をとる。
FreeBSDではデフォルトで /usr/sbin/ntpd がインストール済みである。
▼設定ファイル(ntp.conf)を修正する。
日本標準時を得るためのサーバは、インターネットマルチフィード株式会社の「時刻情報提供サービス for Public」【NTPの使い方 UNIX (Linuxなど) の場合】を利用した。
日本標準時(JST)グループのNICT公開NTP FAQでは
RFC-4330 10-6 および 10-7 でIPアドレスによる指定ではなく、ホスト名による設定が "SHOULD" とされています。
と記載されているため、IPアドレスではなくドメイン名で指定した。RFC-4330
そして、restrict 192.168.0.0 mask 255.255.255.0 noquery nomodify nopeer notrap を追記して、LAN内の機器に同期を許可する設定を行った。
下記追加した。
# vi /etc/ntp.conf
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst
restrict 192.168.0.0 mask 255.255.255.0 noquery nomodify nopeer notrap
restrict source limited kod nomodify notrap noquery
▼起動設定追加
# vi /etc/rc.conf
ntpd_enable="YES"
ntpd_program="/usr/sbin/ntpd"
ntpd_config="/etc/ntp.conf"
▼起動する
# /etc/rc.d/ntpd start
Starting ntpd.
▼ログ確認
# tail -30 /var/log/messages
Dec 11 13:47:56 www ntpd[613]: ntpd exiting on signal 15 (Terminated)
Dec 11 13:47:56 www ntpd[3438]: ntpd 4.2.8p15-a (1): Starting
Dec 11 13:47:56 www ntpd[3438]: Command line: /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift
Dec 11 13:47:56 www ntpd[3438]: ----------------------------------------------------
Dec 11 13:47:56 www ntpd[3438]: ntp-4 is maintained by Network Time Foundation,
Dec 11 13:47:56 www ntpd[3438]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
Dec 11 13:47:56 www ntpd[3438]: corporation. Support and training for ntp-4 are
Dec 11 13:47:56 www ntpd[3438]: available at https://www.nwtime.org/support
Dec 11 13:47:56 www ntpd[3438]: ----------------------------------------------------
Dec 11 13:47:56 www ntpd[3439]: line 42 column 0 syntax error, unexpected T_String, expecting $end
Dec 11 13:47:56 www ntpd[3439]: syntax error in /etc/ntp.conf line 42, column 0
Dec 11 13:47:56 www ntpd[3439]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): good hash signature
Dec 11 13:47:56 www ntpd[3439]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): loaded, expire=2022-06-28T00:00:00Z last=2017-01-01T00:00:00Z ofs=37
Dec 11 13:47:56 192.168.0.x NTP[006]: Unsuitable data in NTP header
▼ntpqコマンドで確認
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+ntp2.jst.mfeed. 133.243.236.18 2 u 53 64 77 22.543 +24.412 67.769
*ntp3.jst.mfeed. 133.243.236.19 2 u 7 64 377 21.950 +87.962 52.993
▼ゲストOS:Debian GNU/Linux 10.7のNTPクライアントの設定
# apt -y install ntp
vi /etc/ntp.conf
#pool 0.debian.pool.ntp.org iburst
#pool 1.debian.pool.ntp.org iburst
#pool 2.debian.pool.ntp.org iburst
#pool 3.debian.pool.ntp.org iburst
コメントアウト
サーバ追加
server 192.168.0.201
▼ntp再起動
# systemctl restart ntp
ntpq -pで同期すると、下記のエラーが出る(-_-;)
localhost: timed out, nothing received
***Request timed out
/etc/ntp.confに、下記を追記した。
#restrict default ignore
restrict ::1
restrict 127.0.0.1
▼同期確認
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*www.server-bff. 210.173.160.57 3 u 54 64 377 0.977 2.451 46.056
LAN内のNASにも、NTPサーバを指定した。
以上