【问题标题】:Firewalld configuration seems ignored on centos 7.3在 centos 7.3 上似乎忽略了防火墙配置
【发布时间】:2017-01-04 13:40:24
【问题描述】:

我想只允许使用 firewalld 在我的 centos 7.3 服务器上对某些 IP 范围进行 http 访问。 所以这里是我的防火墙规则

firewall-cmd  --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens160
  sources:
  services: dhcpv6-client ssh
  ports:
  protocols:
  masquerade: no
  forward-ports:
  sourceports:
  icmp-blocks:
  rich rules:
        rule family="ipv4" source address="x.x.x.x/22" port port="80" protocol="tcp" accept
        rule family="ipv4" source address="192.168.209.0/24" port port="80" protocol="tcp" accept
        rule family="ipv4" source address="1.2.3.4/32" port port="80" protocol="tcp" reject
        rule family="ipv4" source address="0.0.0.0/0" port port="80" protocol="tcp" reject

但我仍然可以从端口 80 上的 x.x.x.x 访问,但我不明白为什么

使用 IP 表,这里是使用我的 firewalld conf 创建的内容

Chain IN_public_allow (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh ctstate NEW
ACCEPT     tcp  --  x.x.x.x/22      anywhere             tcp dpt:http ctstate NEW
ACCEPT     tcp  --  X.X.X.X/16        anywhere             tcp dpt:http ctstate NEW
ACCEPT     tcp  --  ipgg.sdv.fr          anywhere             tcp dpt:http ctstate NEW
ACCEPT     tcp  --  x.x.x.x/24       anywhere             tcp dpt:http ctstate NEW
ACCEPT     tcp  --  x.x.x.x/24     anywhere             tcp dpt:http ctstate NEW

Chain IN_public_deny (1 references)
target     prot opt source               destination
REJECT     tcp  --  ns3098611.ip-94-23-44.eu  anywhere             tcp dpt:http ctstate NEW reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             anywhere             tcp dpt:http ctstate NEW reject-with icmp-port-unreachable

但似乎从未考虑过。 相反,我认为这条规则首先适用

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere

我从零开始,这里是我的历史

1208 服务泊坞窗停止 第1209章 1210 sudo iptables -P 转发接受 1211 sudo iptables -P 输出接受 第1214章 第1215章 第1216章 1217 服务泊坞窗启动 1221 防火墙-cmd --list-all

我只看到通过链输入的流量

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
  513 38048 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0
 2698  382K INPUT_direct  all  --  *      *       0.0.0.0/0            0.0.0.0/0
 2698  382K INPUT_ZONES_SOURCE  all  --  *      *       0.0.0.0/0            0.0.0.0/0
 2698  382K INPUT_ZONES  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    3   132 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate INVALID
 2691  382K REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

【问题讨论】:

    标签: iptables centos7 firewalld


    【解决方案1】:

    您的默认策略是接受,因此除非有丢弃或拒绝规则,否则所有内容都将被接受。但是,更重要的是,您的第一条规则似乎专门允许从 x.x.x.x 到端口 80 的流量?

    你也可以检查 ipv6,你所有的规则都是针对 ipv4 的,所以如果 ipv6 处于活动状态,它可能是完全开放的。

    【讨论】:

    • 感谢您的评论 @user2612030 但 x.x.x.x 是出于安全原因(不想发布我的 IP)。如果我为任何地方添加拒绝规则,我不想让 ssh 断开连接。我的需要只是只接受来自 IP 范围的 http 连接。
    猜你喜欢
    • 2016-10-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    • 2013-09-12
    • 2015-06-12
    • 2020-07-08
    • 2020-03-29
    • 1970-01-01
    相关资源
    最近更新 更多