我想我已经要求 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)
Run Code Online (Sandbox Code Playgroud)
这是否意味着 iptables 处于非活动状态?我是否必须“应用”规则或是否在 Debian 上默认停用 iptables?
小智 6
您正在接口 eth0 上设置 iptables 规则,但 telnet 到 localhost,这是接口 lo,因此被您的 iptables 规则忽略。
尝试 telnet 到 eth0 的 ip 地址,看看是否得到相同的结果
归档时间: |
|
查看次数: |
382 次 |
最近记录: |