NTP time server for the LAN server synchronization time use, you can all the time to ensure that LAN time server time server consistent, some real-time applications
with high requirements must be unified time. Internet time server, there are many, such as ntpdate ntp.fudan.edu.cn complex
NTP Fudan University offers free internet time synchronization. NTP server listens on UDP port 123, it would need to open the run client access port 123 in the local firewall
centos 6 under
vi / etc / sysconfig / iptables add the following rules:
-A INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT
Under centos 7
firewall-cmd --zone=public --add-port=123/udp --permanent
firewall-cmd --reload
NTP time server configuration:
yum -y install ntp ntpdate
modify the configuration file ntp.conf
grep -n "^[a-z]" /etc/ntp.conf #过滤配置文件
4:driftfile /var/lib/ntp/drift #默认的
9:restrict default nomodify #注释掉地8行,添加这行,表示nomodify客户端可以同步时间。
14:restrict 127.0.0.1 #默认的
15:restrict ::1 #默认的
26:server ntp1.aliyun.com #添加时间源
27:server time.nist.gov #添加时间源
39:includefile /etc/ntp/crypto/pw #以下都是默认的
43:keys /etc/ntp/keys
61:disable monitor
Start Time Server
systemctl start ntpd
netstat -lnuto|grep 123 #查看端口
udp 0 0 192.168.122.1:123 0.0.0.0:* off (0.00/0/0)
udp 0 0 192.168.3.144:123 0.0.0.0:* off (0.00/0/0)
udp 0 0 127.0.0.1:123 0.0.0.0:* off (0.00/0/0)
udp 0 0 0.0.0.0:123 0.0.0.0:* off (0.00/0/0)
udp6 0 0 fe80::d391:779c:b33:123 :::* off (0.00/0/0)
udp6 0 0 ::1:123 :::* off (0.00/0/0)
udp6 0 0 :::123 :::* off (0.00/0/0)
After starting the confirmation:
#ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*120.25.115.20 10.137.53.7 2 u 12 64 7 32.328 3.748 1.922
203.107.6.88 100.107.25.114 2 u 11 64 7 21.925 0.144 1.553
Two found time resources available
Wait a few minutes, the client synchronization time
1, time synchronization with a time server
ntpdate -d 192.168.3.144
2, set the time synchronization scripts
crontab -l
*/5 * * * * ntpdate 192.168.3.144 >/dev/null 2>&1* * * * ntpdate 192.168.56.100 >/dev/null 2>&1
So far, the network time server's installation is complete, all the network servers can be synchronized to a time server time, you do not need to go to a public Internet time synchronization.