一、检查服务是否安装
*检查ntp服务是否安装
[root@localhost tzp]# rpm -qa |grep ntp
ntp-4.2.6p5-19.el7.centos.3.x86_64(有这个就跳过只有一个安装包,可以用rpm)
并设置系统开机自动启动并启动服务
[root@localhost tzp]# systemctl enable ntpd
[root@localhost tzp]# systemctl start ntpd
二、 设置ntp服务器: 192.168.0.101
修改/etc/ntp.conf文件
只注释部分
参数参考:
一般允许ntp服务参数
nomodify 客户端不能使用 ntpc 与 ntpq 两支程式来修改服务器的时间参
数
notrap 不提供 trap 这个远程时间登录的功能
拒绝的不提供时间:
noquery: 客户端不能使用 ntpq、ntpc 等指令来查询服务器时间,等于
提供 ntp 的网络校时
nopeer 不与其他同一层的 ntp 服务器进行时间同步
server IP 地址 //上层时间服务器 实验中用#不生效
restrict default nomodify notrap nopeer noquery //允许所有的访问(大约在第六行)
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap(//允
许同步时间的客户机以192.168.0.0网段为列,提供时服务)
指定服务器为本地服