小编rsa*_*bir的帖子

iptables 规则不起作用

我面临以下问题:我想阻止从网络访问端口 8000(阻止除 127.0.0.1 之外的所有连接)。因此,为了简化我的问题,作为第一步,我决定使用以下规则阻止对端口 8000 的所有访问:

iptables -A INPUT -p tcp --dport 8000 -j DROP
Run Code Online (Sandbox Code Playgroud)

现在,我知道我应该采取相反的方法,即删除除受信任的连接之外的所有连接,但我决定出于教育目的而这样做。

iptables -L显示了这个输出:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8000

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
DOCKER     all  --  0.0.0.0/0            0.0.0.0/0
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           ctstate RELATED,ESTABLISHED
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain DOCKER (1 references)
target …
Run Code Online (Sandbox Code Playgroud)

iptables

3
推荐指数
1
解决办法
4215
查看次数

标签 统计

iptables ×1