点击(此处)折叠或打开
-
NTP服务器监听端口为UDP的123,需要在本地防火墙开启运行客户端访问123端口;
- echo '-A INPUT -m state --state NEW -m udp -p udp --deport 123 -j ACCEPT'>> /etc/sysconfig/iptables
- ntp服务安装与配置
- yum install ntp ntpdate -y
- /etc/init.d/ntpd restart
-
同步nptd时间服务器时间
- ntpd -p
- 同步/etc/ntp.conf中的外网时间服务器
-
/etc/init.d/ntpd stop
- ntpdate pool.ntp.org
-
29 Nov 01:42:23 ntpdate[2115]: adjust time server 85.199.214.101 offset 0.015287 sec
-
点击(此处)折叠或打开
-
#安装ntpdate
-
yum -y install ntp
-
#编辑计划任务
-
crontab -e
-
0 0 * * * /usr/sbin/ntpdate 192.168.199.125 >>/var/log/ntpstats/ntp.log 2>&1
-
#编辑/etc/ntp.conf配置
-
vim /etc/ntp.conf
-
driftfile /var/lib/ntp/drift
-
restrict default kod nomodify notrap nopeer noquery
-
restrict -6 default kod nomodify notrap nopeer noquery
-
#开启内部递归网络接口lo
-
restrict 127.0.0.1
-
restrict -6 ::1
-
#上级时间服务器
-
server 192.168.199.125
-
fudge 192.168.199.125 stratum 10
-
includefile /etc/ntp/crypto/pw
- keys /etc/ntp/keys
-
- ntpdate 192.168.199.125
-
29 Nov 01:42:23 ntpdate[2115]: adjust time server 85.199.214.101 offset 0.015287 sec