0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux] クロック設定_NTP, ntpq, ntpd, /etc/ntp.conf

Last updated at Posted at 2025-06-18

ntpq コマンド

$ ntpq [オプション]
オプション 由来 説明
default NTP query ntpデーモン(ntpd)と通信して、現在の時刻同期状態などを確認・制御するNTPクライアントコマンド
対話モードで起動
-p peers 接続中の NTP サーバとの接続状態を一覧表示
- 遅延、オフセット、状態などを含む
-i interactive mode 対話モードで起動
- peersassoc などを打てる
  • ntpq -pn出力
    image.png
項目 要点(試験対策として重要な部分のみ)
remote 時刻同期先のホスト。* は現在の同期先、+ は候補、- は無視するサーバ。
refid 同期開始時に.INIT.と表示、stratum 1 の場合は.GPS.など表示される。
st stratum 値(時刻の階層レベル)。小さいほど上位(信頼性が高い)。
when 最後にパケットを交換してからの経過秒数。
poll 時刻問い合わせの間隔(秒)。安定すると自動で長くなる。
reach 通信の成功回数(8ビットのビット列、例:377=8回成功、376=7回成功など)。
delay 往復の遅延時間(ミリ秒)。
offset サーバとの時刻のズレ(ミリ秒)。
jitter 時刻同期のズレ具合(ミリ秒)。

/etc/ntp.conf

  • ntpd による NTP(Network Time Protocol) の設定ファイル
  • システムクロックをインターネット上やローカルネットワークの時刻サーバと同期するために使用される
  • 解説

/etc/ntp.conf の記載例(pool.ntp.org使用)

/etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift

pool 0.pool.ntp.org iburst
pool 1.pool.ntp.org iburst
pool 2.pool.ntp.org iburst
pool 3.pool.ntp.org iburst

restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1

/etc/ntp.confの主な設定項目

設定項目 説明
server 同期するNTPサーバを指定
例:server pool.ntp.org iburst
peer 他のNTPサーバと対等に時刻を同期
例:peer 192.168.0.10
(LAN内で相互同期を行う場合など)
restrict クライアントのアクセス制御
例:restrict default nomodify notrap nopeer noquery
接続元に応じた制限を細かく設定可能
driftfile クロックのずれを補正するドリフト値の保存先
例:driftfile /var/lib/ntp/drift

iburst: 起動直後にNTPサーバに対して短い間隔で4回問い合わせることで時刻同期を速めるオプション
pool.ntp.org: 複数のNTPサーバをまとめて仮想的なNTPサーバとして運用し負荷分散の技術の一つである「DNSラウンドロビン」方式で時刻を提供

補足:NTPパッケージ

  • CentOS, RHEL: ntp パッケージ(/etc/ntp.conf を読み込み)
  • Ubuntu: ntp パッケージ(/etc/ntp.conf を読み込み)
  • CentOS 8 以降: chrony パッケージ(/etc/chrony.conf を読み込み)

参考リンク

Ping-t

ntpq

ntpd

/etc/ntp.conf

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?