$ tar xzf ntp-4.1.1b.tar.gz $ cd ntp-4.1.1b ntp-4.1.1b$ ./configure ntp-4.1.1b$ make ntp-4.1.1b$ su ntp-4.1.1b# make install ntp-4.1.1b# cp scripts/rc1/xntp /etc/rc.d/init.d/. ntp-4.1.1b# chmod 755 /etc/rc.d/init.d/xntp ntp-4.1.1b# cat > /etc/ntp.confntp-4.1.1b# vi /etc/rc.d/init.d/xntp
#!/bin/sh # chkconfig: 345 55 45 # description: ntp 4.1.1b killproc() { # kill named processes pid=`/bin/ps -e | /bin/grep $1 | /bin/sed -e 's/^ *//' -e 's/ .*//'` [ "$pid" != "" ] && kill $pid } case "$1" in 'start') ps -e | grep ntpd > /dev/null 2>&1 if [ $? -eq 0 ] then echo "ntp daemon already running. ntp start aborted" exit 0 fi if [ -f /etc/ntp.conf -a -x /usr/local/bin/ntpd ] then /usr/local/bin/ntpd -c /etc/ntp.conf fi ;; 'stop') killproc ntpd ;; *) echo "Usage: /etc/init.d/xntp { start | stop }" ;; esac
パケットフィルタ (iptables) が効いている場合、パケットが捨てられないようにするために /etc/sysconfig/iptables に-A RH-Lokkit-0-50-INPUT -p udp -m udp --dport 123 -j ACCEPT NTP は UDP ポート 123 で通信しますを書きます。 ntp-4.1.1b# /etc/rc.d/init.d/iptables restart 変更を反映
$ ntptrace ntp サーバのトレース (ルートへ) $ ntpq -p 動作確認 remote refid st t when poll reach delay offset jitter =============================================================================== +ntp1.example.jp ntp-tk02.ocn.ad 4 u 11 64 1 0.770 0.790 0.004 *ntp2.example.jp ntp-tk02.ocn.ad 4 u 11 64 1 0.770 0.790 0.004 ' ' タイムアウトで対象から外された 'x' falseticker で対象から外された '.' 参照サーバが多すぎて対象から外された '-' クラスタリングチェックで対象から外された '+' 参照可能サーバ '#' 参照可能サーバ (距離が遠い) '*' 同期中サーバ 'o' PPS 同期中サーバ (PPS:PulsePerSecond) remote ソースホスト名 refid 更に上のソースホスト名 st stratum 番号 t 階層タイプ l:local u:unicast m:multicast b:broadcast when 最後のパケットを受け取ってからの経過秒数 poll ポーリング秒数 reach 到達可能レジスタ (8 進数) delay ポーリングインターバルの遅延予測時間 (ミリ秒) offset 階層のオフセット (ミリ秒) jitter 階層の分散 (ミリ秒)
ntp server