First, installation environment:
CentOS 7 Linux version 3.10.0-229.el7.x86_64
Ntp-4.2.6p5-19.el7.centos.x86_64
Second, installation and configuration
2.1 Installation
NTP can be installed directly from Yum, using Rpm-qa NTP to see if the NTP service is installed, or if it can be upgraded with Yum install NTP, or without upgrading.
Command:
Yum Install NTP #安装NTP服务器
2.2 Configuration
Cat/etc/ntp.conf
# For more information on this file, see the "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 #默认配置, no need to change
# Permit time synchronization with We time source, but does not
# permit the source to a query or modify the service on this system.
Restrict default nomodify notrap nopeer noquery #默认配置, no changes required
# Permit All access over the loopback interface. This could
# is tightened as well, but to does so would effect some of
# the administrative functions.
Restrict 127.0.0.1 #默认配置, no need to change
Restrict:: 1 #默认配置, no changes required
# Hosts on local network is less restricted.
#restrict 192.168.1.0 Mask 255.255.255.0 nomodify notrap
Restrict 192.168.30.0 mask 255.255.255.0 nomodify notrap #增加这一行, which IP addresses can be synchronized to the NTP server, or not configured, all network segments by default
# 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
#默认配置, can not change, in mainland China will default to use the mainland's primary NTP server, Hong Kong will use the NTP server. Of course, you can also annotate the above four lines and add them yourself, such as server 0.210.72.145.44
#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 #默认配置, no need to change
# key file containing the keys and Key identifiers used when operating
# with symmetric key cryptography.
Keys/etc/ntp/keys #默认配置, no need to change
# Specify the key identifiers which is 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'll is disabled with the limited restriction flag.
Disable Monitor #默认配置, no changes required
2.3 Starting the NTP service
Command:
Systemctl Start Ntpd.service Open service
Systemctl Stop Ntpd.service Service
Third, testing
Command:
Ntpstat #查看ntp服务器是否连通, it takes 35 minutes to connect after starting the service
Ntpq-p #查看ntp服务器连接状态
NETSTAT-TUNLP | grep ntpd #查看服务端口
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/82/A7/wKiom1deJrGRxhrOAAB6GsIteXU540.jpg "/>650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/82/A7/wKiom1deJrHCVwtlAADCdOtwrPQ145.jpg "/>650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/82/A6/wKioL1deJ8Ly_3SlAAB3c1VnNiQ372.jpg "/>
Test if NTP synchronization is available on another Linux
Command:
Yum Install Ntpdate
Ntpdate 172.31.251.196
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/82/A7/wKiom1deJrKwy7tMAAA60-x1dao326.jpg "/>
Iv. Synchronization of Switches
Configuration command:
Conf t
NTP server 172.31.251.196
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/82/A7/wKiom1deJrPTbpTMAAGWud0NL2U661.jpg "/>
Thank you for opening this blog post, and always adhere to see here, if you feel helpful, please do not skimp on the lower right corner of the praise.
This article is from the "Bit Technology" blog, please be sure to keep this source http://tryrus.blog.51cto.com/10914693/1788562
CentOS7.0 installing NTP server and Cisco switch NTP synchronization