CentOS NTP服务搭建

前端之家收集整理的这篇文章主要介绍了CentOS NTP服务搭建前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.试验环境

  • CentOS Linux release 7.0.1406 (Core)
  • 2台虚拟机
  • @H_301_8@
    名称 操作系统 IP
    master centos7 192.10.200.81
    slave1 centos7 192.10.200.85
    • 已经设置好hosts文件
    • @H_301_8@

      2.安装服务端

      yum -y install ntp
      service ntpd status
      systemctl enable ntpd  
      service ntpd start vi /etc/ntp.conf

      修改下游主机

      restrict 192.10.200.0 mask 255.255.255.0 nomodify notrap
      restrict ::1

      其格式是:

      restrict [ip] mask [mask] [parameter]

      参数值说明

      参数 说明
      ignore 居然所有类型的ntp连接
      nomodify 不允许客户端修改服务器的时间参数,但是允许客户端透过这部主机进行时间校验。
      noquery 不允许客户端进行时间校验。
      notrap 不提供trap时间登录
      notrust 拒绝没有认证的客户端

      如有需要,修改上游主机

      server 0.centos.pool.ntp.org iburst

      重启

      service ntpd restart
      ntpstat   # 查看状态

      3.安装客户端

      yum install ntp
      systemctl enable ntpd  
      vi /etc/ntp.conf

      修改配置

      server master
      restrict 172.16.248.1 nomodify notrap noquery
      
      server 127.0.0.1
      fudge 127.0.0.1 stratum 10
      systemctl restart ntpd

      4.测试

      在客户机上执行

      date -s 20000101
      ntpdate -u master
      ntpd -q
      ntpdstat

      防火墙

      iptables -A INPUT -s 192.168.1.0/24 -p udp --dport 123 -j ACCEPT
      #iptables -A INPUT -p udp --dport 123 -j DROP 其它来源丢弃

猜你在找的CentOS相关文章