1. Build NTP time server

Time:2022-5-4

NTP server time

NTP server is used for time synchronization of LAN servers, which can ensure that the time of all servers in LAN is consistent with that of time server. Some applications that require high real-time performance of time must unify the time.

There are also many time servers on the Internet, such asntpdate ntp. fudan. edu. Cn NTP of Fudan University provides Internet time synchronization for free.

If the listening port of NTP server is UDP 123, you need to open the running client access port 123 in the local firewall, and add the following rules to VI / etc / sysconfig / iptables

 

-A INPUT -m state –state NEW -m udp -p udp –dport 123 -j ACCEPT 

NTP time server configuration: Yum install NTP ntpdate – y install NTP package!

 

vi /etc/ntp. Conf only modify the following two lines and remove the # number!

 

server 127.127.1.0     # local clock                        fudge  127.127.1.0 stratum 10

 

 

 

 

 

restrict default ignore

#Turn off all NTP request packets

restrict 127.0.0.1

#Open the internal recursive network interface lo

restrict 192.168.0.0 mask 255.255.255.0 nomodify

#The client in the internal subnet can conduct network timing, but cannot modify the time parameters of the NTP server.

server 192.168.1.147.22

#192.168.1.147.22 is the reference of superior time server

restrict 192.168.1.127

#Open server access to our NTP services

driftfile /var/lib/ntp/drift

The time spent in contacting the superior file is recorded in the time spent with the superior file

2. Start NTP time server: service ntpd start

3. Set NTP boot auto start: chkconfig ntpd on

4. Check whether NTP works normally: netstat – tlunp | grep NTP

5. Configure firewall filtering rules: / SBIN / iptables – I input – P UDP — dport 123 – J accept