centos 搭建ntp服务

一、NTP服务端

1、安装ntp包

  yum install ntp

2、修改/etc/ntp.conf配置文件


driftfile /var/lib/ntp/drift

restrict 127.0.0.1 

restrict 192.168.6.0 mask 255.255.255.0 nomodify

restrict -6 ::1

server ntp.api.bz prefer

server ch.pool.ntp.org

server 0.asia.pool.ntp.org

server 1.asia.pool.ntp.org

server 2.asia.pool.ntp.org

server 127.127.1.1

fudge 127.127.1.1 stratum 10 refid NIST

driftfile /var/lib/ntp/drift

broadcastdelay  0.008

logfile /var/log/ntp.log

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys


3、启动ntp服务

service ntpd start


4、修改/etc/sysconfig/ntpd文件,将系统时间同步到BIOS

添加一下内容:

SYNC_HWCLOCK=yes


4、查看ntp运行状态

ntpstat

ntpq -p



二、ntp客户端同步

0 5 * * * ntpdate 192.168.6.119 >> /root/ntpdate.log 2>&1


你可能感兴趣的:(ntp)