企业内部在centos7.2系统中必杀技NTP时间服务器及内网服务器时间同步(windows和linux客户端同步)...

本文介绍了如何在CentOS7.2系统中搭建和配置NTP服务器,以及如何使内网的Linux和Windows客户端进行时间同步。通过设置NTP服务,可以方便地统一企业内部成百上千台计算机的时间,避免因时间不一致带来的问题。详细步骤包括安装ntp服务、配置NTP服务器和客户端,以及解决可能出现的同步错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

网络时间协议NTP(Network Time Protocol)是用于互联网中时间同步的标准互联网协议。NTP的用途是把计算机的时间同步到某些时间标准。目前采用的时间标准是世界协调时UTC(Universal Time Coordinated)。NTP的主要开发者是美国特拉华大学的David L. Mills教授。


NTP对于我们个人来说有什么用呢,简单的讲,当你的计算机时间不准确了,你可以接入到互联网,从网上同步一下时间。

对于企业来说,当你有成百上千的计算机,都不能直接连接互联网,时间不统一影响业务,如果一台一台的修改,工作量太大。这时搭建一个自己的NTP服务器就显出它的优势了。


企业内部架设NTP服务器的大概拓扑如下:



配置好相关的yum源、确保你的ntp服务器可以连网
# vim /etc/resolv.conf
#添加网关,这个可以ipconfig查看默认网关
nameserver 192.168.8.251

配置内网NTP-Server(192.168.8.100)


1、yum安装ntp服务

# yum install -y ntp


配置开机启动
# chkconfig ntpd on
# chkconfig --list ntpd
ntpd           0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭

2、编辑ntp的配置文件

# vim /etc/ntp.conf 添加如下内容就可以了

 

# 允许内网网段 192.168.0.0 其他机器同步时间
restrict 192.168.0.0 mask 255.255.0.0 nomodify
 
# 中国这边最活跃的时间服务器 : http://www.pool.ntp.org/zone/cn
server ntp.api.bz perfer   	
server 210.72.145.44		 # 中国国家受时中心
server 202.112.10.36             # 1.cn.pool.ntp.org
server 59.124.196.83             # 0.asia.pool.ntp.org
# 允许上层时间服务器主动修改本机时间
restrict ntp.api.bz nomodify notrap noquery
restrict 210.72.145.44 nomodify notrap noquery
restrict 202.112.10.36 nomodify notrap noquery
restrict 59.124.196.83 nomodify notrap noquery


# 外部时间服务器不可用时,以本地时间作为时间服务
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10




最终的参数:
# cat /etc/ntp.conf |awk '{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}'
或者
# cat /etc/ntp.conf | grep "^[^#]"

driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 
restrict -6 ::1
restrict 192.168.0.0 mask 255.255.0.0 nomodify
server ntp.api.bz perfer
server 210.72.145.44             # 中国国家受时中心
server 202.112.10.36             # 1.cn.pool.ntp.org
server 59.124.196.83             # 0.asia.pool.ntp.org
server  127.127.1.0     # local clock
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
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys



国内常用的时间服务器列表:

210.72.145.44  (国家授时中心服务器IP地址)
ntp.sjtu.edu.cn 202.120.2.101 (上海交通大学网络中心NTP服务器地址)
s1a.time.edu.cn	北京邮电大学
s1b.time.edu.cn	清华大学
s1c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值