NTP 服务器配置

 

服务器端配置

1,  下载安装ntp软件包

apt-get installntp

2,  配置/etc/ntp.conf文件

server  210.72.145.44 prefer   #prefer 表示首选

dirftfile /etc/ntp/drift#记录上传NTP与上层NTPserver连接所话费的时间

restrict defaultignore #默认任何主机进行时间同步

restrict 127.0.0.1

restrict 192.168.10.2# 指定某台机器时间同步

restrict 192.168.0.0 mask255.255.255.0 #允许192.168.0.0/254子网内主机时间同步

restrict 0.0.0.0 mask 0.0.0.0nomodify notrap #允许任何主机跟进行时间同步

 

fudge127.127.1.1 stratum 10 #指定阶层编号为10,降低其优先级

 

statsdir /var/log/ntp/#设置ntp日志的path

 

logfile/var/log/ntp/ntp.log #设置ntp日志文件

3,  维护ntp服务

#chkconfig–level 345 ntp on

--启动、停止

# service ntpdstart|stop

#/etc/rc.d/init.d/ntpdrestart

4,管理命令

#ntpq –n #查看本机和上层服务器的时间同步结果

#nettrace #可以用来追踪某台时间服务器的时间对应关系

#ntpdate IP #客户端要和NTPserver 进行时钟同步

 

2,客户端配置

      #echo “0 */1 * * * root /usr/sbin/ntpdate172.16.31.13; /sbin/hwclock -w”>>/etc/crontab

crontab–h #查看帮助