【问题标题】:Iptable does not drop incoming or out going packetsiptable 不会丢弃传入或传出的数据包
【发布时间】:2013-06-14 03:19:45
【问题描述】:

我正在使用 CentOS。

我在我的 IPTable 测试环境中完成了以下操作。我已经使用

刷新了所有规则
    iptables -F 

然后我添加了以下规则。

    iptables -I INPUT -p all -j ACCEPT

然后根据观察,我添加了这条规则;

    iptables -A INPUT -s 192.168.2.50 -j DROP

我已经运行了

    service iptable save

之后我尝试 ping 被阻止的 ip (192.168.2.50)。我还是能ping通,被屏蔽的ip也能ping通。

我想阻止来自被阻止 IP 的任何传入连接。

这是 iptables -L

的输出
    Chain INPUT (policy DROP) target prot opt source destination

    ACCEPT all -- anywhere anywhere
    DROP all -- 192.168.2.50 anywhere

    Chain FORWARD (policy DROP) target prot opt source destination

    Chain OUTPUT (policy ACCEPT) target prot opt source destination

    Chain icmp_packets (0 references) target prot opt source destination

    Chain tcp_packets (0 references) target prot opt source destination

请帮忙..谢谢..

【问题讨论】:

  • 你有多个接口吗?
  • 没有。只有一个 1. eth0 接口而已。如果我有多个接口会有什么区别?

标签: centos iptables


【解决方案1】:

Iptables 使用规则链。在链中,规则按顺序应用于数据包,从第一个(顶部)到最后一个。 您的第一条规则ACCEPT all -- anywhere anywhere 让所有通过链的数据包都被接受,因此它们不会进一步进入下一个应该丢弃所有的规则。 因此,如果您只想将所有流量丢弃到您的机器,只需使用iptables -D INPUT 1 删除您的第一条规则,这将删除输入链中的第一条规则,只留下全部丢弃规则。然后用iptables -A INPUT -p all -j ACCEPT再次添加accept all规则,这样所有不是来自被阻塞ip的数据包都会被允许通过。

【讨论】:

    【解决方案2】:

    我认为你应该这样做 iptables -A INPUT -s 192.168.2.50 -j DROPiptables -I INPUT -p all -j ACCEPT之前。

    【讨论】:

      猜你喜欢
      • 2014-05-18
      • 2019-07-25
      • 1970-01-01
      • 2010-09-17
      • 2015-03-05
      • 1970-01-01
      • 2010-10-21
      • 2021-05-01
      相关资源
      最近更新 更多