Centos7搭建NTP服务

1.1 查看系统是否已经安装ntp服务组件

rpm -qa | grep "ntp"                #<==查看是否已经安装ntp组件,有如下两个组件说明已经安装
ntpdate-4.2.6p5-1.el6.centos.x86_64
ntp-4.2.6p5-1.el6.centos.x86_64

 1.2 yum安装

yum -y install ntp

1.3 ntp服务器端的配置


1.3.1 配置文件
Ø  配置文件

/etc/ntp.conf


Ø  配置文件默认内容

egrep -v "^$|#" /etc/ntp.conf        #<==排除默认注释及空行
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery     #<==对默认的client拒绝所有操作
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1      #<==允许本地地址的一切操作                             
restrict -6 ::1
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

Ø  修改配置

cat /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery     #<==对默认的client拒绝所有操作
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1                                      #<==允许本机的一切操作
restrict 192.168.1.0 mask 255.255.255.0 nomodify    #<==允许局域网内所有client连接到这台服务器
restrict -6 ::1                                         同步时间.但是拒绝让他们修改服务器上的时间
#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
server ntp1.aliyun.com          #<==同步公网的时间
server 127.127.1.0              #<==如果无法连接公网,则使用自己本身的时间作为标准时间。
fudge 127.127.1.0 stratum 10    #<==设置stratum级别
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

1.4服务启动

systemctl start ntpd
systemctl enable ntpd

1.5客户端同步

yum -y install ntpdate
ntpdate -u IP地址(ntp服务的IP地址)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值