一、安装NTP服务

yum -y install ntp ntpdata


二、设置防火墙策略

firewall-cmd --zone=public --add-port=123/udp --permanent  #开放UDP 123端口

firewall-cmd --reload


三、编辑NTP配置文件

vim /etc/ntp.conf

添加:

server 210.72.145.44 prefer      #优先使用国家授时服务器

server 127.127.1.0 iburst          #若网络授时服务器不可用,则使用本地授时服务器

fudge 127.127.1.0 stratum 10

restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap      #允许使用这个ntp的网段


四、关闭chronyd 服务

centos7 默认使用 chronyd来进行时间同步,所以使用ntp服务前需要关闭 chronyd

systemctl status chronyd

systemctl disable chronyd


五、查看ntp服务器与上层NTP的连通性

ntpstat