美文网首页
linux时间同步ntp服务的安装与配置

linux时间同步ntp服务的安装与配置

作者: 闽越布衣 | 来源:发表于2020-09-08 10:48 被阅读0次

安装NTP(server client)

yum install ntp -y

Server机器修改NTP配置文件,添加NTP服务器的网络位置 vi /etc/ntp.conf

# For more information about this file, see the man pages
# ntp.conf(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 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 ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# 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
#用本地时间做为服务器时间
server 172.16.177.128
fudge 172.16.177.128 stratum 8
#开放172.16.0.0 整个网段,即在这个网段的所有机器都可以使用 172.16.177.128 作为时间同步服务端
restrict 172.16.0.0 mask 255.255.255.0 nomodify notrap
#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

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor

设置完成退出保存,然后启动ntp服务

systemctl start ntpd.service  #启动服务
systemctl enable ntpd.service #设置为开机启动

Client机器修改NTP配置文件,添加NTP服务器的网络位置 vi /etc/ntp.conf

# For more information about this file, see the man pages
# ntp.conf(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 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 ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# 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
#增加172.16.177.128作为时间服务器即可
server 172.16.177.128
#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

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor

相关文章

  • CentOS安装ntp时间同步服务

    CentOS安装ntp时间同步服务 安装ntp 服务端配置 配置文件路径:/etc/ntp.conf [图片上传失...

  • Linux同步服务器时间

    Linux同步服务器时间 CentOS安装ntp时间同步服务[https://blog.csdn.net/yinj...

  • 笔记 时间同步服务器搭建

    ntp配置 需要搭建本地的时间同步服务器(非授时)参考:1.CentOS 6 安装 NTP Server 时间服务...

  • (8)Linux_服务篇_NTP_DHCP

    NTP 描述:中心时间服务器,用于局域网服务器时间同步 安装软件:ntp 1. 配置路径:vim /etc/ntp...

  • 使用NTP时间同步

    安装ntp 1.安装软件 2.配置ntp启动项 3.同步时间 4.启动ntpd服务 配置时间源 配置是否为其他PC...

  • 配置集群时间同步

    配置集群时间同步: 1.时间服务器配置(必须root用户) 检查ntp是否安装 2.修改ntp配置文件 [root...

  • centos6-ntpd安装部署

    NTPD服务端 安装NTP软件: 检查远程ntp服务器是否可用: 配置ntp服务之前,先手动同步一下时间: 编辑N...

  • linux时间同步ntp服务的安装与配置

    安装NTP(server client) Server机器修改NTP配置文件,添加NTP服务器的网络位置 vi ...

  • 集群时间同步

    时间同步的方式: 配置时间同步具体实操: 时间服务器配置(必须root用户) (1)检查ntp是否安装 (2)修改...

  • ntp同步局域网下的时间

    时间服务器配置 查看ntp是否安装 修改ntp配置文件 修改授权网段,使得该网段的所有机器可以查询和同步本主机的时...

网友评论

      本文标题:linux时间同步ntp服务的安装与配置

      本文链接:https://www.haomeiwen.com/subject/aajdektx.html