当前位置:网站首页>NTP服务器搭建
NTP服务器搭建
2022-07-29 15:09:00 【星哥玩云】
NTP的用途是把计算机的时钟同步到世界协调时UTC,NTP可以使计算机对其服务器或时钟源进行时间同步。
以下为NTP服务器搭建和客户端同步配置
一、服务端配置 1、安装NTP软件包
执行命令:yum install ntp ntpdate -y
2、修改NTP配置文件,修改前注意先备份。
执行命令:cp /etc/ntp.conf{,.bak} #备份ntp配置文件
vim /etc/ntp.conf
restrict 控制相关权限
ignore :关闭所有的 NTP 联机服务
nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap :,不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。
nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟
kod : 访问违规时发送 KoD 包。
restrict -6 表示IPV6地址的权限设置。
restrict default kod nomodify notrap nopeer noquery #首先我们对于默认的client拒绝所有的操作
restrict 127.0.0.1 #允许本机地址的一切操作
restrict 192.168.182.0 mask 255.255.255.0 nomodify notrap #在该子网里面的客户端可以进行网络校时,但是不能修改NTP时间服务器的时间参数,不提供trap远端登陆
server 127.127.1.0 #新增上级时间服务器为本机 fudge 127.127.1.0 stratum 10 #设置时间服务器的层次,
3、启动服务前,可以手动更新一下服务器的时间
执行命令:ntpdate cn.ntp.org.cn
4、以守护进程启动ntpd,并将ntpd服务添加到防火墙策略里面
执行命令:service ntpd start #启动ntpd服务
firewall-cmd --add-service=ntp --permanent #添加服务到防火墙
firewall-cmd --reload #重启防火墙
二、客户端配置
1、修改客户端配置文件,修改内容如下:
注释掉自带的时间服务器,并新增 时间服务器
2、配置防火墙
执行命令:firewall-cmd --add-service=ntp --permanent #添加服务到防火墙
firewall-cmd --reload #重启防火墙
3、启动ntpd,并查看ntp同步状态
执行命令:service ntpd start #启动ntp服务
ntpq -p #观察时间同步状况
ntpstat #查看时间同步结果
三、客户端配置同步时间任务
执行命令:crontab -e #编辑定时任务
在弹框内输入如下内容:
0 0 * * * /usr/sbin/ntpdate 192.168.182.140 >>/usr/local/logs/crontab/ntpdate.log #每天24点更新同步时间
至此ntp-server和ntp-client部署完成。
边栏推荐
- Linux环境 redis完整配置及启动命令
- LeetCode·3.无重复字符的最长子串·滑动窗口
- 浮点数内存存储问题
- Immediate experience with CTS - | D further promotion application equipment compatibility
- BGP联邦实验
- Qt learning on the first day
- Shell脚本编程-运算
- 药品研发--质理研究人员绩效办法
- 【 LeetCode 】 88. Merging two orderly array
- I quit my job after cutting the brothers, and turned to do a small clerk
猜你喜欢

Micro combat | centralized configuration service center Config asymmetric encryption and security management

我裁完兄弟们后,辞职了,转行做了一名小职员

bit field in c language

文档贡献与写作必读-OpenHarmony开发者文档风格指南

Why does APP use the JSON protocol to interact with the server: serialization related knowledge

网络知识大集合(最详细)与网络通信过程

ES6 from entry to master # 11: the Map data type

LeetCode·621.任务调度器·构造法

NLP自然语言处理-机器学习和自然语言处理介绍(一)

NDK 系列(5):JNI 从入门到实践,爆肝万字详解!
随机推荐
Jmeter实现多用户测试
error #6633: The type of the actual argument differs from the type of the dummy argument.
The very city live 丨 being - Unicorn: towards the unification of target tracking (ECCV2022 Oral)
CSP:重庆八中宏帆初级中学校新初二编程社C2024liuyanjia暑假一期集训总结(2/6))
Face key point prediction and normalization
电子元器件行业B2B交易系统:规范企业交易流程,提升销售管理效率
ES6 从入门到精通 # 11:Map 数据类型
怎么建立数据分析思维
网络知识大集合(最详细)与网络通信过程
微服务实战|集中配置中心Config非对称加密与安全管理
Shell script programming - operation
Altair SimSolid complex assembly meshless rapid structure simulation online seminars
I/O代码实践
bit field in c language
不会多线程还想进BAT?精选19道多线程面试题,有答案边看边学
SkiaSharp 之 WPF 自绘 弹动小球(案例版)
Linux环境 redis完整配置及启动命令
进入中国27年,又一美妆巨头要离场
错误# 6633:实际的类型参数不同于空变量的类型。
数字赋能机械制造业,供应链协同管理系统解决方案助力企业供应链再升级