下面的xml内容显示了我创建的防火墙规则。有两个状态为"拒绝"的规则是避免与服务器的 ssh 连接的方法。但它不起作用。它允许连接。 我做了防火墙-cmd重新加载。另一个 icmp 规则工作正常,但不确定 ssh 出了什么问题。
请帮忙。
<?xml version="1.0" encoding="utf-8"?>
<direct>
<rule priority="0" table="filter" ipv="ipv4" chain="INPUT">-p all --state RELATED,ESTABLISHED -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
<rule priority="0" table="filter" ipv="ipv4" chain="INPUT">-p icmp -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
<rule priority="0" table="filter" ipv="ipv4" chain="INPUT">-p all -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
<rule priority="0" table="filter" ipv="ipv4" chain="INPUT">-p tcp -s 0.0.0.0/0 -d 0.0.0.0/0 --dport 22 -j REJECT</rule>
<rule priority="0" table="filter" ipv="ipv6" chain="INPUT">-p all --state RELATED,ESTABLISHED -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
<rule priority="0" table="filter" ipv="ipv6" chain="INPUT">-p icmp -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
<rule priority="0" table="filter" ipv="ipv6" chain="INPUT">-p all -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
<rule priority="0" table="filter" ipv="ipv6" chain="INPUT">-p tcp -s 0.0.0.0/0 -d 0.0.0.0/0 --dport 22 -j REJECT</rule>
</direct>
原因是端口未对 sshd 服务开放。 在我添加sshd_config行的文件中,
Port 5670
然后运行以下命令
firewall-cmd --add-port=5670/tcp --permanent
systemctl restart sshd