1、检查是否已经安装ntp# rpm -qa|grep ntpntp-4.2.4p8-2.el6.centos.i686
2、配置ntp.conf# vim /etc/ntp.conf需要修改以下几项:restrict:表示设置客户端连接到本NTP服务器的权限其规则为:restrict ip mask netmask_ip parameter其中IP 可以是地址位,也可以是default;parameter有以下选项:ignore:关闭所有的NTP链接服务nomodify:表示client不能更改server端的参数信息notrust:该client除非通过认证,否则该客户端的来源将被视为不信任网域noquery:不提供客户端的时间查询server:表示设置本NTP服务器连接到远程NTP服务器的地址server 127.127.1.0fudge 127.127.1.0 stratum 10以上两行表示如果server指定的服务器连接失败,则采用本地的时间来同步时间配置日志:statsdir /var/log/ntp/logfile /var/log/ntp/ntp.log
3、简单配置如下
4、启动ntp# mkdir -p /var/log/ntp && touch /var/log/ntp/ntp.log# chkconfig ntpd on# service ntpd start
5、客户端测试通过linux客户端测试ntp server# ntpdate 192.168.0.45 Aug 15:43:22 ntpdate[30958]: adjust time server 192.168.0.4 offset 0.000576 sec