暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

局域网内的ntp时钟同步服务配置

数据管理员 2022-06-01
2281

局域网内配置NTP时钟服务

用途
IP地址
系统版本
NTP server192.168.78.119redhat6.10
NTP client192.168.78.120redhat6.10
NTP client192.168.78.121redhat6.10

1,server端验证NTP是否已安装

    #rpm -qa ntp*
    ntpdate-4.2.6p5-12.el6_9.2.x86_64
    ntp-4.2.6p5-12.el6_9.2.x86_64


    如果没有安装,可以使用rpm或者yum进行安装

    2,server端配置ntp.conf文件,添加以下内容

      #vi etc/ntp.conf


      server 127.127.1.0 #local clock
      fudge 127.127.1.0 stratum 10
      retrict 192.168.78.120 mask 255.255.255.0 nomodify
      retrict 192.168.78.121 mask 255.255.255.0 nomodify


      注释:如果在不连接上层服务器的情况(即以此台服务器192.168.78.119用做局域网内部时钟服务),
      需要添加server 127.127.1.0和fudge 127.127.1.0 stratum 10
      这个配置是让NTP server以自己为上层服务器,内网环境可以选择这样配置)

      3,server端启动ntp服务

        #service ntpd start


        查看ntp状态


        # ntpstat
        synchronised to local net at stratum 11 
          time correct to within 11 ms
          polling server every 64 s
        # ntpq -p
            remote          refid      st t when poll reach  delay  offset  jitter
        ==============================================================================
        *LOCAL(0) .LOCL. 10 l 17 64 377 0.000 0.000 0.000

        4,server端设置开机自启动

          #chkconfig ntpd on

          5,客户端配置(客户端地址为192.168.78.120/192.168.78.121)

            # crontab -l


            */5 * * * * /usr/sbin/ntpdate 192.168.78.117
            0 0 * * * usr/sbin/hwclock -w


            */5表示每5分钟同步一次时间
              参数详解:


              # vi /etc/ntp.conf


              #系统时间与BIOS事件的偏差记录
              driftfile /var/lib/ntp/drift
              restrict default kod nomodify notrap nopeer noquery    # 拒绝所有IPv4的client连接此NTP服务器
              restrict -6 default kod nomodify notrap nopeer noquery    # 拒绝所有IPv6的client连接此NTP服务器
              restrict 127.0.0.1    # 放行本机localhost对NTP服务的访问
              restrict -6 ::1
              # Hosts on local network are less restricted.
              #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap    # 放行192.168.1.0网段主机与NTP服务器进行时间同步
              # Use public servers from the pool.ntp.org project.
              # Please consider joining the pool (http://www.pool.ntp.org/join.html).
              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
              #broadcast 192.168.1.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
              # Enable public key cryptography.
              #crypto
              includefile /etc/ntp/crypto/pw
              # Key file containing the keys and key identifiers used when operating
              # with symmetric key cryptography. 
              keys /etc/ntp/keys


              文章转载自数据管理员,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

              评论