LoginSignup
3
4

More than 5 years have passed since last update.

debianでNTPサーバ・クライアント

Posted at

1.環境

Virtual Boxのdebian9にNTPを3台

2.NTPサーバ

NTPのインストール

apt -y install ntp

設定ファイルの編集

vim /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に127.127.1.0を指定すると、NTPサーバが時間を合わせる基準として自分自身のローカルクロックを使用する。
server 127.127.1.0
50行目に時刻同期を許可する範囲を追記
restrict 10.0.2.0 mask 255.255.255.0 nomodify notrap

・再起動
systemctl restart ntp

3.NTPクライアント

NTPクライアントのインストール

apt -y install ntp

設定ファイルの編集

vim /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にNTPサーバのIPアドレスを設定
server 10.0.2.1

・再起動
systemctl restart ntp

4.動作確認

サーバ側でntpq -pすると自サーバをサーバとした時刻同期が行われている
クライアント側でntpq -pするとサーバ側と時刻同期が行われている

4その他

IPアドレスなどは自分の環境に合わせて設定してください。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4