NTPによる時刻同期(Debian GNU Linux)
ntpによる時刻同期方法
環境
- OSはDebian GNU/Linux.
- Internetは,ブロードバンドルータによりフレッツADSLで常時接続.
設定手順
- rootまたはsudoでapt-getを行う.
$ sudo apt-get install ntp
これにより,2003/6/12現在ではntpとntp-simpleがインストールされます.
- /etc/ntp.confを修正する
修正が必要な箇所は server 行だけでよい.たとえば,以下のように修正する.
server ntp1.jst.mfeed.ad.jp server ntp2.jst.mfeed.ad.jp server ntp3.jst.mfeed.ad.jp
- ブロードバンドルータの設定で「port 123 TCP/UDP」のリクエストをntpを起動するパソコンへ向ける.
ブロードバンドルータにより設定が異なる.私が使用しているI/O DATA NP-BBRsxでは「バーチャルサーバ」の設定で行う.
- ntpq -pを実行し動作しているかをチェックする.
$ ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== +ntp1.jst.mfeed. mf-isdn3.mfeed. 2 u 71 1024 377 35.645 0.550 0.054 *ntp2.jst.mfeed. mf-isdn1.mfeed. 2 u 571 1024 377 36.396 0.609 0.305 +ntp3.jst.mfeed. mf-isdn1.mfeed. 2 u 102 1024 377 36.045 0.828 0.122「*」があるサーバーが時刻同期に使用されている.
- LAN内のPCからのアクセスを許可する -- 2003/10/25追加
/etc/ntp.conf に以下の行を追加する。
$ vi /etc/ntp.conf [/etc/ntp.conf] restrict 192.168.0.0 mask 255.255.0.0 notrust nomodify notrap
Copyright (C) 2003-2006 A.SAKAKI All Rights Reserved.
パソコンでサーバーを構築して、自宅サーバにしよう。