2024年4月24日发(作者:)
目标环境,若干台linux centos, 一台作为NTPD服务与公共NTP服务同步时间,同时作
为内网的NTPD服务器,其他机器与这台服务做时间同步。
服务器IP 角色 说明
1、负责与公共NTPD服务同步标准时间
2、作为内部网络的NTPD服务
同步方式
NTPD服务平滑同步
NTPD服务平滑同步
NTPD服务平滑同步
10.221.25.100
NTPD服务
内部NTP客户端 内网设备与10.221.25.100同步时间
……
1、安装配置
内部NTP客户端 内网设备与10.221.25.100同步时间
CentOS 6.4系统已经自带了NTPD服务,一般默认是按照了的,如果没有安装,先检查下,
然后配置好yum仓库,yum方式安装下就OK,具体如下:
# rpm -q ntp
6.x86_64 // 这表示已安装了,如果没有安装,这是空白。
如果没有安装,我们按照下
# yum install ntp
......
按上面的安装方式在内网每台服务器上都安装好NTP软件包。
完成后,都需要配置NTP服务为自启动
//开机自动运行
# chkconfig ntpd on
# chkconfig --list ntpd
ntpd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
若为上述显示,则自启动成功。
在配置前,先使用ntpdate手动与时钟服务同步下时间,免得本机与外部时间服务器时间差
距太大,让ntpd不能正常同步。例:
# ntpdate -u 202.112.10.36
15 Jul 16:52:38 ntpdate[4164]: adjust time server 202.112.10.36 offset 0.012135 sec
2、配置内网NTP-Server(10.221.25.100)
#
下面主要是配置内网的NPTD服务器(10.221.25.100), NTPD服务配置核心就在
/etc/文件。红色部分是修改地方,其他的默认。
# For more information about this file, see the man pages
(二级)
# (5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
# 允许内网其他机器同步时间
restrict 10.221.25.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the project.
# Please consider joining the pool (/).
# 配置ip为外放ntp或内部一级ntp服务(10.221.25.1为一级ntp服务,可换其他ip)
server 202.112.10.36
server 10.221.25.1
#broadcast 10.221.25.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# allow update time by the upper server
# 允许上层时间服务器主动修改本机时间
restrict 202.112.10.36 nomodify notrap noquery
restrict 10.221.25.1 nomodify notrap noquery
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
# 外部时间服务器不可用时,以本地时间作为时间服务
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 5
# stratum 5 这行是时间服务器的层次。设为0则为顶级,如果要向别的NTP服务器请求更新时间,


发布评论