**設定 [#g41d4bff]

 # vi /etc/ntp.conf

 # デフォルトの設定は全ホストとのNTP通信を許可しない
 restrict default ignore
 
 # localhostはアクセス制限なし
 restrict 127.0.0.1
 
 # クライアントのアクセス制限
 restrict 192.168.100.2 mask 255.255.255.255 noquery nomodify notrap
 
 # 外部(上層)NTPサーバへのアクセスを許可(下のserverで指定したサーバ)
 restrict 210.173.160.27 mask 255.255.255.255 nomodify notrap noquery
 restrict 210.173.160.57 mask 255.255.255.255 nomodify notrap noquery
 restrict 210.173.160.87 mask 255.255.255.255 nomodify notrap noquery
 
 # 同期源となる上層NTPサーバを指定
 #server 0.pool.ntp.org
 #server 1.pool.ntp.org
 #server 2.pool.ntp.org
 server ntp.jst.mfeed.ad.jp
 server 210.173.160.27   # ntp1.jst.mfeed.ad.jp
 server 210.173.160.57   # ntp2.jst.mfeed.ad.jp
 server 210.173.160.87   # ntp3.jst.mfeed.ad.jp
 
 # fudgeはローカル時計の優先順位を設定してるっぽい
 # 上で設定した上層のNTPサーバ(ntp1.jst.mfeed.ad.jp)がstratum 2なので3にしてみた
 # でも他のサイトの説明とかを見てもデフォルトの10だったり
 # コメントアウトしたりstratumをかかなかったりしてバラバラなので
 # これで正解かは微妙
 server  127.127.1.0     # local clock
 fudge   127.127.1.0 stratum 3

**起動 [#ze786d24]

 # /etc/rc.d/init.d/ntpd start

**確認 [#k780a50a]

設定で指定したntpサーバが表示されていればOK

 # /usr/sbin/ntpq -p
      remote           refid      st t when poll reach   delay   offset  jitter
 ==============================================================================
 *ntp3.jst.mfeed. 210.173.176.4    2 u   25   64   77   10.864   42.169  11.804
  ntp1.jst.mfeed. 210.173.160.56   2 u   15   64    1    9.320  6707.99   0.001
  ntp2.jst.mfeed. 210.173.160.86   2 u   14   64    1    9.173  6707.97   0.001
  ntp3.jst.mfeed. 210.173.160.86   2 u   13   64    1    9.271  6707.85   0.001
  LOCAL(0)        LOCAL(0)        10 l   23   64   77    0.000    0.000   0.001

**落とし穴 [#p4d011b6]
-クライアントからの時刻同期はサーバ側を立ち上げて、しばらく時間をおいてからでないと「no server suitable for synchronization found」でエラーになってしまう。
-サーバ側のファイヤーウォールが有効だと123:udpを許可すると良い。

 # nmap -sU localhost


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS