ntpq | ぼぶろぐ

ぼぶろぐ

以前は、あいらぶLinux♪というタイトルでしたが、
最近はLinux以外のことも書いているので、タイトルを変更しました。
ぼぶちゃんのぶろぐでぼぶろぐです。

◆ntpq
ntpサーバとの同期状況などが確認できるコマンド
ntpサーバをたてたら必ずこのコマンドで状態を確認します。

ntpdが稼働していないと使用することができません。


簡易マニュアル

# ntpq -h
ntpq: illegal option -- h
ntpq - standard NTP query program - Ver. 4.2.4p6
USAGE: ntpq [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]
Flg Arg Option-Name Description
-4 no ipv4 Force IPv4 DNS name resolution
-6 no ipv6 Force IPv6 DNS name resolution
-c Str command run a command and exit
-d no debug-level Increase output debug message level
-D Str set-debug-level Set the output debug message level
-p no peers Print a list of the peers
-i no interactive Force ntpq to operate in interactive mode
-n no numeric numeric host addresses
-v opt version Output version information and exit
-? no help Display usage information and exit
-! no more-help Extended usage information passed thru pager
-> opt save-opts Save the option state to a config file
-< Str load-opts Load options from a config file


使用例

# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+144.219.192.61. 192.168.1.1 3 u 7 64 377 54.542 49.754 18.821
+ns2.ktroad.net 210.173.160.57 3 u 2 64 377 29.192 41.013 20.894
*featkyo001216.f 210.173.160.27 3 u 56 64 177 37.539 40.161 15.338

上記の例ですとntp同期の対象を3つ設定しています。
一番左が"*"の上位ntpサーバと同期をとっています。
pollがポーリング間隔で時刻が安定してくると徐々に上位ntpサーバとの
同期時間を長くしていき、最大で1024秒になります。


ntpサーバでntp.nict.jpという日本標準時サーバがあるのですが、
これをntp.confに3つ続けて設定していました。

なんで同じサーバを3つも指定するのかというと、ntp.nict.jpは
DNSラウンドロビンでIPアドレスを4つもっています。

# dig ntp.nict.jp
~略~
;; ANSWER SECTION:
ntp.nict.jp. 3600 IN A 133.243.238.244
ntp.nict.jp. 3600 IN A 133.243.238.163
ntp.nict.jp. 3600 IN A 133.243.238.164
ntp.nict.jp. 3600 IN A 133.243.238.243

なので、タイミングが悪いと1つしか同期対象になりませんが、
たいていは3つ同期対象になります。