Debian 11にNTP サーバーをインストールする

2021年12月26日

環境情報
osバージョンを確認します
# cat /etc/debian_version
11.2

インストールの方法
1.ntpをインストールします
# apt -y install ntp

2.ntpの配置ファイルを設定します
# vi /etc/ntp.conf

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
23~26行目 デフォルト設定をコメントします
#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
pool ntp.nict.jp iburst
23~26行目 デフォルト設定をコメントします #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 pool ntp.nict.jp iburst
23~26行目 デフォルト設定をコメントします
#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
pool ntp.nict.jp iburst

50行目 時刻同期を許可する範囲を設定します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
修正前
#restrict 192.168.123.0 mask 255.255.255.0 notrust
修正後
restrict 192.168.71.0 mask 255.255.255.0 nomodify notrap
修正前 #restrict 192.168.123.0 mask 255.255.255.0 notrust 修正後 restrict 192.168.71.0 mask 255.255.255.0 nomodify notrap
修正前
#restrict 192.168.123.0 mask 255.255.255.0 notrust
修正後
restrict 192.168.71.0 mask 255.255.255.0 nomodify notrap

3.ntpを再起動します
# systemctl restart ntp

4.動作確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
ntp.nict.jp .POOL. 16 p - 64 0 0.000 +0.000 0.000
*ntp-b3.nict.go. .NICT. 1 u 16 64 1 9.377 -2.508 2.902
+ntp-b2.nict.go. .NICT. 1 u 13 64 1 11.656 -3.803 4.369
+ntp-k1.nict.jp .nict. 1 u 14 64 1 16.389 -2.033 2.752
ntp-a2.nict.go. .NICT. 1 u 10 64 1 8.986 -2.445 2.290
ntp-a3.nict.go. .NICT. 1 u 9 64 1 9.435 -2.412 1.119
# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== ntp.nict.jp .POOL. 16 p - 64 0 0.000 +0.000 0.000 *ntp-b3.nict.go. .NICT. 1 u 16 64 1 9.377 -2.508 2.902 +ntp-b2.nict.go. .NICT. 1 u 13 64 1 11.656 -3.803 4.369 +ntp-k1.nict.jp .nict. 1 u 14 64 1 16.389 -2.033 2.752 ntp-a2.nict.go. .NICT. 1 u 10 64 1 8.986 -2.445 2.290 ntp-a3.nict.go. .NICT. 1 u 9 64 1 9.435 -2.412 1.119
# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp.nict.jp     .POOL.          16 p    -   64    0    0.000   +0.000   0.000
*ntp-b3.nict.go. .NICT.           1 u   16   64    1    9.377   -2.508   2.902
+ntp-b2.nict.go. .NICT.           1 u   13   64    1   11.656   -3.803   4.369
+ntp-k1.nict.jp  .nict.           1 u   14   64    1   16.389   -2.033   2.752
 ntp-a2.nict.go. .NICT.           1 u   10   64    1    8.986   -2.445   2.290
 ntp-a3.nict.go. .NICT.           1 u    9   64    1    9.435   -2.412   1.119

 

Debian 11

Posted by arkgame