gpt4 book ai didi

centos - Iptable 不会丢弃传入或传出的数据包

转载 作者:太空宇宙 更新时间:2023-11-03 17:18:39 24 4
gpt4 key购买 nike

我正在使用 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

请帮忙..谢谢..

最佳答案

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

关于centos - Iptable 不会丢弃传入或传出的数据包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17159917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com