I. Installing the NTP software
1. Check if the NTP-related package is installed. Rpm-qa | grep ntp2. Install NTP software. Yum-y Install NTP Two. Parameter explanation ignore: Turn off all NTP Online Services Nomodify: The client cannot change the time parameters on the server side, but the client can perform the network calibration via the server. Notrust: Unless authenticated, the client source will be treated as untrusted subnet Noquery: The client's time query is not provided: The user cannot query the NTP server using commands such as Ntpq,ntpc Notrap : does not provide a trap remote login: denies the Mode 6 Control message Trap Service for the matching host. The Trap service is a subsystem of the NTPDQ Control Message Protocol, which is used for remote event logger applications. Nopeer: Used to prevent the host from trying to peer to the server and allow the fraudulent server to control the clock KoD: The KoD package is sent when an access violation occurs. Three. Modify the configuration file 1. View unmodified Profiles # grep ^[^#]/etc/ntp.conf driftfile/var/lib/ntp/driftrestrict default Nomodify notrap nopeer noqueryrestrict 127.0.0.1restrict:: 1server 0.centos.pool.ntp.org iburstserver 1. centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburstincludefile/etc/ntp /crypto/pwkeys/etc/ntp/keysdisable Monitor1. Setting allows clients of any IP to have time synchronization (modified configuration file) # grep ^[^#]/etc/ntp.conf driftfile/var/lib/ntp/driftrestrict default Nomodify notraprestrict 127.0.0.1restrict:: 1server 0. centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3. Centos.pool.ntp.org iburstincludefile/etc/ntp/crypto/pwkeys/etc/ntp/keysdisable Monitor2. Allow time synchronization only for clients of 192.168.1.0 segments (modified configuration file) # grep ^[^#]/etc/ntp.conf driftfile/var/lib/ntp/ Driftrestrict default nomodify notrap nopeer noqueryrestrict 127.0.0.1restrict:: 1restrict 192.168.1.0 Mask 255.255.255.0 nomodify Notrapserver 0.CENTOS.POOL.Ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.ntp.org iburstserver 3.centos.pool.ntp.org Iburstincludefile/etc/ntp/crypto/pwkeys/etc/ntp/keysdisable Monitor Four. Start the NTP service and firewall systemctl start Ntpdsystemctl enable ntpdiptables-a input-p udp-i eno16777736-s 192.168.1.0/24--dport 12 3-j acceptsetsebool-p Ntp_disable_trans 1#selinux settings vi/etc/sysconfig/ntpd# allow the BIOS to synchronize with the system time, add the following line. Sync_hwclock=yes Five. Detect NTP1. Detect if NTP service is running # NETSTAT-TLUNP | grep ntpudp 0 0 192.168.1.101:123 0.0.0.0:* 2563/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 2563/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 2563/ntpd udp6 0 0 fe80::20c:29ff:fe7b:123:::* 2563/ntpd udp6 0 0::1:123 :::* 2563/ntpd udp6 0 0:::123 :::* 2563/ntpd 2. View NTP server has no and upper NTP connectivity # ntpstatsynchronised to NTP Server (120.25.108.11) at Stratum 3 time correct to within the ms polling server every S3. View NTP Service State of the Upper NTP # ntpq-p remote refid St T when poll reach delay offset jitter============ ================================================================== news.neu.edu.cn. init. u - 64 0 0.000 0.000 0.000x202.118.1.130 202.118.1.47 2 u 7 64 377 153.659 9.605 19.941 *time4.aliyun.co 10.137.38.86 2 u 10 64 377 39.666& nbsp -47.661 15.944 Remote-the IP or hostname of the native and upper NTP, "+" is preferred, "*" indicates secondary priority REFID-refer to the previous level of NTP host address st-stratum hierarchy when-how many seconds ago had synchronized time poll-next more New in how many seconds after reach-the number of updates that have been requested for the upper NTP server delay-network delay offset-time compensation jitter-system time vs. BIOS difference Six. Configure time synchronization Client 1. Execute ntpdate command: Ntpdate 192.168.1.101 #192.168.1.101 for NTP server IP address 2. Write Bioshclock-w3.crond service vi/etc/ CRONTAB30 8 * * * root/usr/sbin/ntpdate 192.168.1.101; /sbin/hwclock-w4. Restarting the Crond Services service Crond restart
Configuring the NTP time server