IPPurpose192.168.11.212ntpd server, used to synchronize the standard time with the external public ntpd 172.16.248.129ntpd client, used to synchronize the time with ntpd 172.16.248.130ntpd client, used to synchronize time with ntpd 172,16, 248.20.ntpd Client3. Check whether the service is installed
- Use rpm to check whether the ntp package is installed
[root@localhost kevin]# rpm -q ntpntp-4.2.6p5-19.el7.centos.3.x86_64
- Skip this step if you have installed yum. Otherwise, use yum to install yum and set the system to automatically start and start the service.
[root@localhost kevin]# yum -y install ntp[root@localhost kevin]# systemctl enable ntpd[root@localhost kevin]# systemctl start ntpd
4. Set ntp server: 192.168.11.212
Run the following command before Configuration:ntpdate -u cn.pool.ntp.org
, Synchronization server
- Modify the/etc/ntp. conf file. The red font indicates the modified content.
# 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 cocould# Be tightened as well, but to do so wocould effect some# The administrative functions.Restrict 127.0.0.1Restrict: 1# Hosts on local network are less restricted.# Restrict 192.168.1.0 mask limit 255.0 nomodify notrapRestrict 172.16.248.0 mask limit 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 iburstServer 2.cn.pool.ntp.orgServer 1.asia.pool.ntp.orgServer 2.asia.pool.ntp.org# 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.415254.254 # manycast server# Manycastclient 239.415254.254 autokey # manycast client# Allow the upper-layer time server to actively modify the local timerestrict 2.cn.pool.ntp.org nomodify notrap noqueryrestrict 1.asia.pool.ntp.org nomodify notrap noqueryrestrict 2.asia.pool.ntp.org nomodify notrap noqueryserver 127.0.0.1 # local clockfudge 127.0.0.1 stratum 10# Enable public key cryptography.#cryptoincludefile /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
Restart the ntpd service after modification.systemctl restart ntpd
Use ntpq-p to view the NTP server in the network and display the relationship between the client and each server.
Use the ntpstat command to view the time synchronization status. This usually takes 5 to 10 minutes to connect and synchronize successfully. Therefore, wait a moment after the server is started:
When starting, it is generally:
# ntpstat unsynchronised time server re-starting polling server every 64 s
After connection and synchronization:
# ntpstat synchronised to NTP server (202.112.10.36) at stratum 3 time correct to within 275 ms polling server every 256 s
5. Set the ntp client: 172.16.248.129 | 130 | 131
Install the ntp service and set it to automatic start, which is the same as the preceding setting. Then edit the/etc/ntp. conf file. The red font is the changed content.
# 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.1restrict ::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 iburstserver 172.16.248.1restrict 172.16.248.1 nomodify notrap noqueryserver 127.0.0.1fudge 127.0.0.1 stratum 10#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.#cryptoincludefile /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
Restart ntpd service
#systemctl restart ntpd
View synchronization status after startup
# ntpq -p# ntpstat
Because it is an intranet, ntpstat can be synchronized soon.