Lin*_*eak 2 linux iptables port-forwarding
我在 Linux Mint 上。
我在我的路由器上分配了一个公共静态地址,并手动转发了一个给定的端口进行种子下载,所以不是通过 UPnP,我在路由器和传输 bittorrent 应用程序中都禁用了它。
从某种意义上说,传输显示端口已打开。但是当传输关闭时,端口也应该关闭,据我所知。
但是有新的数据包被接受iptables
,尽管传输是关闭的。
为什么?我能做什么?
这是iptables -L -v
:
# iptables -L -v
Chain INPUT (policy DROP 7514 packets, 585K bytes)
pkts bytes target prot opt in out source destination
251 10040 DROP all -- any any anywhere anywhere ctstate INVALID
4330 371K DROP icmp -- any any anywhere anywhere
0 0 DROP igmp -- any any anywhere anywhere
4394 850K ACCEPT all -- lo any anywhere anywhere
1324K 462M ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED
6751 415K ACCEPT tcp -- any any anywhere anywhere tcp dpt:56874
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1484K packets, 2391M bytes)
pkts bytes target prot opt in out source destination
Run Code Online (Sandbox Code Playgroud)
一分钟后也是一样:
# iptables -L -v
Chain INPUT (policy DROP 7869 packets, 611K bytes)
pkts bytes target prot opt in out source destination
251 10040 DROP all -- any any anywhere anywhere ctstate INVALID
4330 371K DROP icmp -- any any anywhere anywhere
0 0 DROP igmp -- any any anywhere anywhere
4437 863K ACCEPT all -- lo any anywhere anywhere
1324K 462M ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED
6983 430K ACCEPT tcp -- any any anywhere anywhere tcp dpt:56874
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1485K packets, 2391M bytes)
pkts bytes target prot opt in out source destination
Run Code Online (Sandbox Code Playgroud)
至于评论:
netstat -nap | grep <my port number here>
Run Code Online (Sandbox Code Playgroud)
该命令显示空结果。
Tho*_*ker 12
当端口关闭时丢弃数据包不是 iptables 的工作,这是普通网络堆栈的工作(如没有 iptables)。(准确地说:网络堆栈不只是丢弃数据包,它还礼貌地通知对方没有任何东西在监听。)
仅仅因为 iptables 接受一个数据包并不意味着有任何东西在监听。
更新:如评论中所述,存在风险。但这不是因为在封闭端口上接受数据包本身,而是因为与所有其他端口相比,该端口上的行为差异:丢弃与拒绝。解决方案是不丢弃所有其他端口上的数据包,而是像网络堆栈一样拒绝它们:
如果数据包是 TCP,请使用-j REJECT --reject-with tcp-reset
,对于 UDP 和其他基于端口的协议,请使用-j REJECT --reject-with icmp-port-unreachable
。由于每个简单的 DROP 现在都分为两个规则,因此最好创建一个新链,仅用于拒绝并跳转到您之前想要删除的任何地方。
使用端口映射器nmap
来检查结果。
归档时间: |
|
查看次数: |
921 次 |
最近记录: |