ntpdの設定

#contentsx


タイムサーバNTPの設定。
自サーバは外部のNTPサーバと時刻同期を行い、内部のクライアントからの時刻同期に応答する。
設定ファイルは/etc/ntp.conf

設定ファイルの編集

# vi /etc/ntp.conf

ntpdの通信をデフォルトで拒否

# Prohibit general access to this service.
restrict default ignore


通信を許可する外部NTPサーバの設定

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict 133.100.11.8 mask 255.255.255.255 noquery nomodify notrap
restrict 133.100.9.2 mask 255.255.255.255 noquery nomodify notrap
restrict 210.173.160.27 mask 255.255.255.255 noquery nomodify notrap

NTPサーバにアクセスできるクライアントのネットワークの設定

# -- CLIENT NETWORK -------
# Permit systems on this network to synchronize with this
# time service.  Do not permit those systems to modify the
# configuration of this service.  Also, do not use those
# systems as peers for synchronization.
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

同期を行うNTPサーバのIPアドレスの設定

# restrict mytrustedtimeserverip mask 255.255.255.255 nomodify notrap noquery
# server mytrustedtimeserverip
server 133.100.9.2
server 133.100.11.8
server 210.173.160.27

NTPサーバ認証設定

認証が必要であればyes なければno。もしくはコメントアウトする。

authenticate no

認証に使うキー情報

未使用ならコメントアウト。

#keys            /etc/ntp/keys

この二行はコメントアウトする

# server 66.187.233.4
# fudge  127.127.1.0 stratum 10

NTPサーバの起動

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

NTPサーバの自動起動

# /sbin/shkconfig ntpd on

動作確認

# /usr/sbin/ntpq -p

コマンドを入力すると下記内容が表示される。

    remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
clock.tl.fukuok .GPS.            1 u    3   64    1  458.659    4.297   0.008
clock.nc.fukuok .GPS.            1 u   13   64    1  603.304  -45.629   0.008
ntp1.jst.mfeed. fs-monntp1.mfee  2 u   10   64    1  416.315   15.997   0.008

10分程度起動したままにすると行頭に*+がつく。

     remote           refid      st t when poll reach   delay   offset  jitter
 ==============================================================================
*clock.tl.fukuok .GPS.            1 u    3   64    1  458.659    4.297   0.008
+clock.nc.fukuok .GPS.            1 u   13   64    1  603.304  -45.629   0.008
+ntp1.jst.mfeed. fs-monntp1.mfee  2 u   10   64    1  416.315   15.997   0.008

この表示になると通信が確立されたことになる。

最終更新:2010年09月20日 22:41