局域网ntp服务搭建(无网)

1.条件:

1)centos自带有ntp服务

2)局域网的ip假设如下:

192.168.184.11(ntp本地服务器)

192.168.184.12

192.168.184.13

3)目的:因为没网,但又要时间同步,所以只能在本地服务器上设置好时间(与北京时间差不多),然后其他主机与该本地服务器时间同步即可。

 

2.做法

1)在192.168.184.11(即本地服务器)中的做法如下:

①data -s "具体年月日时分秒"

②vim /etc/ntp.conf

③在该文件下添加如下内容并保存:

# 允许内网其他机器同步时间
restrict 192.168.184.0 mask 255.255.255.0 nomodify notrap
# 外部时间服务器不可用时,以本地时间作为时间服务
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 8

④启动ntp服务

cd /usr/lib/systemd/system 
systemctl start ntpd #启动 
systemctl enable ntpd.service #设置开机启动服务 

 

2)在其他节点(比如这边的:192.168.184.12,192.168.184.13)的做法如下:

①执行vim /etc/ntp.conf,加入一下内容:

restrict 127.0.0.1
restrict -6 ::1
 
# 配置时间服务器为本地的时间服务器
server 192.168.184.11
 
restrict 192.168.184.11 nomodify notrap noquery
 
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 8

②手动ntpdate同步:ntpdate -u 192.168.184.11

转载于:https://www.cnblogs.com/lpd1/p/9238153.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值