Linux ntp服务器的配置

上一篇 / 下一篇  2008-04-24 14:19:04 / 个人分类:Linux

ntp服务器端(192.168.1.96)
1. # rpm -ivh ntp-4.1.2-4.EL3.1.i386.rpm
2. # vi /etc/ntp.conf
注释一行
restrict default ignore
加入一行
restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap

#cat /etc/ntp.conf

#restrict default nomodify notrap noquery
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
broadcastdelay  0.008
keys            /etc/ntp/keys

3. # vi /etc/ntp/step-tickers
加入一行
pool.ntp.org
这样每次ntpd启动时,会自动连接该国际标准时间服务器。

4. # service ntpd start

5. # netstat -an |grep 123
确保该端口以udp方式开放。


客户端(192.168.1.30)
1. # ntpdate 192.168.1.96
应该显示同步成功
2. # crontab -e
加入
*/10 * * * * /usr/sbin/ntpdate 192.168.1.96
表示每隔10分钟同步一次时间


[root@game96 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*222.73.214.1    209.81.9.7       2 u   62   64  377   10.434   57.669  25.595
+222.73.214.125  209.81.9.7       2 u   53   64  377   12.487   59.238  36.039
+218.21.130.42   209.51.161.238   2 u   53   64  377   43.089   57.064  38.769
 LOCAL(0)        LOCAL(0)        10 l   58   64  377    0.000    0.000   0.001
这个命令检查时间服务器同步的状态,+代表目前正在使用的NTP服务器,*代表次要NTP服务器。

[root@game96 ~]# ntpstat
synchronised to NTP server (222.73.214.1) at stratum 3
   time correct to within 286 ms
   polling server every 64 s
这个命令列出NTP服务器与上层服务器是否连接。

[root@game96 ~]# ntptrace -n 127.0.0.1
127.0.0.1: stratum 3, offset 0.058552, synch distance 0.388675
222.73.214.1: stratum 2, offset -0.003833, synch distance 0.112924
209.81.9.7: stratum 1, offset 0.000022, synch distance 0.000392, refid 'GPS'
这个命令列出目前我们的NTP服务器与上层NTP服务器彼此之间的关系。


TAG:

引用 删除 Guest   /   2008-05-10 13:50:42
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-09-08  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 1440
  • 日志数: 32
  • 文件数: 2
  • 建立时间: 2008-04-16
  • 更新时间: 2008-08-26

RSS订阅

Open Toolbar