【问题标题】:firewall-cmd tcp ssh REJECT rule not workingfirewall-cmd tcp ssh REJECT 规则不起作用
【发布时间】:2019-12-03 03:33:49
【问题描述】:

下面的 xml 内容显示了我创建的防火墙规则。有两条状态为“REJECT”的规则是为了避免与服务器的 ssh 连接。但它不起作用。它允许连接。 我做了firewall-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>

【问题讨论】:

    标签: centos7 firewalld


    【解决方案1】:

    原因是端口没有为 sshd 服务打开。 在 sshd_config 文件中,我添加了以下行,

    Port 5670
    

    然后运行下面的命令

    firewall-cmd --add-port=5670/tcp --permanent
    systemctl restart sshd
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 2018-11-28
      • 1970-01-01
      • 2022-01-13
      • 2016-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多