Loading

使用ntpdate更新linux时间的时候出现 no server suitable for synchronization found解决办法

问题

在linux下执行/usr/sbin/ntpdate time.nist.gov出现错误提示no server suitable for synchronization found

分析

可能是防火墙造成的

可以先关闭防火墙,然后在执行时间同步的命令,如果时间同步成功则证实是防火墙的问题,须要更改iptables的设置。

关闭防火墙,尝试同步时间

# 关闭防火墙
service iptables stop

# 同步时间
/usr/sbin/ntpdate time.nist.gov

如果上面执行后能正常进行时间的同步,那么证实了是防火墙的设置问题,则开放服务器的tcp和udp协议的123端口。

防火墙设置

# 进栈的udp设置
iptables -s 源地址 -I INPUT -m udp -p udp --dport 123 -j ACCEPT
# 进栈的tcp设置
iptables -A INPUT -s 源地址 -p tcp -m tcp --dport 123 -j ACCEPT

# 出栈的udp设置
iptables -d 目标地址 -I OUTPUT -m udp -p udp --dport 123 -j ACCEPT

# 出栈的tcp设置
iptables -A OUTPUT -d 目的IP -p tcp -m tcp --dport 123 -j ACCEPT

# 保存策略,并重启iptables
service iptables save  
service iptables restart

# 查询iptables是否设置成功
iptables -nvL INPUT |grep "IP地址"
iptables -nvL OUTPUT |grep "IP地址"

检查一下ntpd的服务

检查是否开启,如果已经开启的需要关闭ntpd服务,如不关闭则会报the NTP socket is in use, exiting

service ntpd stop

手动执行时间同步

/usr/sbin/ntpdate time.nist.gov
posted @ 2022-01-28 16:00  ^Mao^  阅读(5925)  评论(0编辑  收藏  举报