Centos 搭建本地NTP服务器。

  环境:Centos7.6centos

  实验主机:A:192.168.2.10服务器

       B:192.168.2.11网络

       C:192.168.2.12(master)spa

  这里选择C作时间服务器。rest

一:安装NTP服务。

yum install ntp -y

二:修改配置文件。

1:C服务器添加以下配置

#restrict default nomodify notrap nopeer noquery  #将这条注释

  restrict 192.168.2.12 nomodify notrap nopeer noquery
  restrict 192.168.2.0 mask 255.255.252.0 nomodify notrap  #容许特定网段能同步时间code


server 127.127.1.0    若是网络时间同步服务器不能够用,就以本地时间为标准想客户端提供服务。 Fudge 127.127.1.0 stratum 10

  #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

  #将网络时间服务地址注释blog

配置解释:
权限的设定主要以 restrict 这个参数来设定,主要的语法为:
restrict IP地址 mask 子网掩码 参数
其中 IP 能够是IP地址,也能够是 default ,default 就是指全部的IP
参数有如下几个:
ignore :关闭全部的 NTP 联机服务
nomodify:客户端不能更改服务端的时间参数,可是客户端能够经过服务端进行网络校时。
notrust :客户端除非经过认证,不然该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询

2:A和B服务器添加以下配置。(注意对应IP)

#restrict default nomodify notrap nopeer noquery    #注释掉
restrict 192.168.2.10 nomodify notrap nopeer noquery
restrict 192.168.2.0 mask 255.255.252.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    
#注释掉以上4条。
server
192.168.2.12 Fudge 192.168.2.12 stratum 10

 

三:启动和自启动NTP服务

systemctl start ntpd
systemctl enable ntpd

  启动后5-10分钟内自动进行同步。同步

四:查看服务状态。

  1:C服务器:ast

  

  2:A服务器:

  

  3:B服务器

  

相关文章
相关标签/搜索