# Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap restrict 192.168.101.0 mask 255.255.255.0 nomodify notrap # 添加本行
# Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). # server 0.centos.pool.ntp.org iburst # 注释本行 # server 1.centos.pool.ntp.org iburst # 注释本行 # server 2.centos.pool.ntp.org iburst # 注释本行 # server 3.centos.pool.ntp.org iburst # 注释本行 server 127.127.1.0# 添加本行 fudge 127.127.1.0 stratum 10# 添加本行
启动NTP
1 2 3 4
[root@localhost ~]# systemctl start ntpd [root@localhost ~]# systemctl enable ntpd Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service. [root@localhost ~]#
查看服务器状态:
1 2 3 4 5
[root@localhost ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *LOCAL(0) .LOCL. 10 l 16410.0000.0000.000 [root@localhost ~]#
在局域网另找一台机器,
1 安装NTP 2 ntpdate 192.168.101.199 # 是NTP Server 192.168.101.199 3 使用 date 命令验证与NTP服务器时间是否统一