Linux Ntp时间同步服务

Linux NTP时间同步服务

记录一下Linux时间同步的方法

1、 服务器

vi /etc/ntp.conf

注释原有的restrict,添加新的restrict,ip是10.10.0.0,表示允许10.10下的所有网段,其他的机器都同步当前这一台服务器的时间

restrict 10.10.0.0 mask 255.255.255.0 nomodify notrap
#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 8
service ntpd start
service ntpd restart
ntpq -p #观察时间同步状况
ntpstat #查看时间同步结果

2、客户端

vi /etc/ntp.conf

注释掉,注释原有的restrict,添加server

#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 10.10.23.3 #时间服务器的ip地址
service ntpd start
service ntpd restart

ntpq -p #观察时间同步状况
ntpstat #查看时间同步结果

3、开机自启动自行添加

#服务器使用的是Centos7 
systemctl start ntpd
posted @ 2020-04-07 12:16  wxzj  阅读(146)  评论(0编辑  收藏  举报