首页 > 其他 > 详细

Centos 搭建本地NTP服务器。

时间:2019-05-08 20:18:51      阅读:144      评论:0      收藏:0      [点我收藏+]

  环境:Centos7.6

  实验主机:A:192.168.2.10

       B:192.168.2.11

       C:192.168.2.12(master)

  这里选择C做时间服务器。

一:安装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  #允许特定网段能同步时间


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 

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

配置解释:
权限的设定主要以 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服务器:

  技术分享图片

  2:A服务器:

  技术分享图片

  3:B服务器

  技术分享图片

 

Centos 搭建本地NTP服务器。

原文:https://www.cnblogs.com/big-cousin/p/10833687.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!