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 Client 3. 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.212Run the following command before configuration: ntpdate-u cn.pool.ntp.org to synchronize the server-Modify/etc/ntp. conf file, the red font is 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 of # the administrative functions. restrict 127.0.0.1 restrict: 1
# Hosts on local network are less restricted. # restrict 192.168.1.0 mask limit 255.0 nomodify notrap restrict 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 iburst server 2.cn.pool.ntp.org server 1.asia.pool.ntp.org server login
# Broadcast 192.168.1.255 autokey # broadcast server # broadcastclient # broadcast client # broadcast multicast autokey # multicast server # multicastclient region # multicast client # manycastserver region # manycast server # manycastclient region autokey # manycast client # Allow the upper-layer time server actively modifies the local time restrict 2.cn.pool.ntp.org nomodify notrap noquery restrict 1.asia.pool.ntp.org nomodify notrap restrict 2.asia.pool.ntp.org nomodify notrap noquery
Server 127.0.0.1 # local clock fudge 127.0.0.1 stratum 10
# Enable public key cryptography. # crypto
Includefile/etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating # with Your Ric 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 systemctl restart ntpd after modification.
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, after the server is started, wait for a moment: when the server is started, 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 | 131Install 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 cocould # be tightened as well, but to do so wocould 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.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 employee iburst server employee restrict 172.16.248.1 nomodify notrap noquery server 127.0.0.1 fudge 127.0.0.1 stratum 10
# Broadcast 192.168.1.255 autokey # broadcast server # broadcastclient # broadcast client # broadcast multicast autokey # multicast server # multicastclient region # multicast client # manycastserver region # manycast server # manycastclient region 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 Your Ric 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 # ntpq-p # ntpstat
Because it is an intranet, ntpstat can be synchronized soon.