我想我已经要求iptables删除端口8091的任何数据包,但tcp连接仍然成功。
$ iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT $ iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT $ iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT $ iptables -A INPUT -i eth0 -j DROP $ iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:ssh ACCEPT tcp -- anywhere anywhere tcp dpt:http ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED DROP all -- anywhere anywhere Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination $ telnet localhost 8091 Trying 127.0.0.1... Connected to localhost.localdomain. Escape character is '^]'. (That means the TCP connection is established, despite the iptables rule)
这是否意味着iptables是无效的? 我需要“申请”规则还是在Debian上默认禁用iptables?
你在接口eth0上设置iptables规则,但telnet到localhost,这是接口lo,因此被你的iptables规则忽略。
尝试telnet到eth0的IP地址,看看你是否得到相同的结果
它看起来像你的configuration应该工作。 我自己复制它,发现虽然我仍然可以从服务器本身访问端口,但从外部访问被阻止。
尝试从另一个位置telnet。