centos7下搭建ntp服务器

服务器端

1.使用yum安装ntp ntpdate;

yum install ntp ntpdate -y

2.查看服务是否安装成功,有相应服务即代表成功;

rpm -qa | grep ntp

在这里插入图片描述3.修改配置文件,使该NTP服务器同步阿里NTP服务器;

vim /etc/ntp.conf
server ntp1.aliyun.com
server ntp2.aliyun.com

在这里插入图片描述4.启动ntp服务,查看状态

systemctl start ntpd

在这里插入图片描述5.查看是否同步

ntpq -p

在这里插入图片描述6.设置开机自启

systemctl enable ntpd

在这里插入图片描述7.设置防火墙,打开udp123端口

firewall-cmd --permanent --add-port=123/udp
firewall-cmd --reload

在这里插入图片描述8.查看端口是否被打开

iptables -L -n

在这里插入图片描述

客户端

1.安装ntp服务同服务器端,查看服务是否安装成功
在这里插入图片描述
2.修改配置文件,将刚刚搭建好的NTP服务器作为客户端上游时间服务器
在这里插入图片描述ps:配置上游时间服务器为本地的ntpd Server服务器
server 172.16.40.130
ps:配置允许上游时间服务器主动修改本机的时间

restrict 172.16.40.130 nomodify notrap noquery

在这里插入图片描述4.与本地ntpd Server同步一下

ntpdate -u 172.16.40.130

在这里插入图片描述5.启动ntp服务

service ntpd start

在这里插入图片描述6.设置ntp服务开机自启
systemctl enable ntpd

7.查看状态
ntpq -p
在这里插入图片描述

  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值