Network Time Protocol:网络时间协议
NTP目的是对网络内所有具有时钟的设备进行时间同步,使设备能够提供基于同一时间的多种应用。
同步本机时间
#!/bin/bash
yum -y install ntp
ntpdate time.windows.com
windows的时间同步服务器个人感觉非常不好用,这里也可以用阿里的服务器
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
将本机制成时间同步服务器
#!/bin/bash
#修改配置文件
sed -i 17c"restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap" /etc/ntp.conf
sed -i 20a"server 127.127.1.0" /etc/ntp.conf
sed -i 21a"fudge 127.127.1.0 stratum 10" /etc/ntp.conf
#添加自启动重启
systemctl enable ntpd
systemctl restart ntpd
#打开firewall端口
firewall-cmd --add-port=123/udp
firewall-cmd --add-port=123/udp --permanent
计算机英语
restrict | 限制 |
stratum | 层 |