Centos 搭建本地NTP服务器。

  环境:Centos7.6

  实验主机:A:192.168.2.10

       B:192.168.2.11

       C:192.168.2.12(master)

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

一:安装NTP服务。#

1
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服务#

1
2
systemctl start ntpd
systemctl enable ntpd

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

四:查看服务状态。#

  1:C服务器:

  

  2:A服务器:

  

  3:B服务器

  

 

posted @   鲜小橙  阅读(9486)  评论(1编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
点击右上角即可分享
微信分享提示
主题色彩