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)と通信し、ステータスやピアの情報などを表示
-p peers 接続中の NTP サーバとの接続状態を一覧表示
- 遅延、オフセット、状態などを含む
-i interactive mode 対話モードで起動(ntpq>プロンプトからコマンド入力が可能)
- peersassoc などを打てる
  • ntpq -pn出力
    image.png

/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

各行の説明(修正後)

説明
driftfile /var/lib/ntp/ntp.drift クロックの誤差(ドリフト)を保存するファイル
pool 0.pool.ntp.org iburst
...
pool 3.pool.ntp.org iburst
複数の NTP サーバプールを指定
可用性や負荷分散に優れる
restrict default nomodify notrap nopeer noquery 外部からのNTP操作を制限
querymodify などの操作を禁止
restrict 127.0.0.1
restrict ::1
ローカルホストからのアクセスを許可

補足:NTPパッケージ

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

参考リンク

Ping-t

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?