如何使用 iptables 将端口 80 限制为只有一个用户
我想限制 80 端口,以便只有一个用户可以使用它。我想用 iptables 来做到这一点,但我没有找到任何有关如何执行此操作的文档。
I want to limit port 80 so that only one user can use it. I want to do this with iptables I have not found any documentation on how to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的意思是“具有离散 uid 的本地用户”,那么您可以使用所有者模块 (
-m Owner
) 和--uid-owner #
选项。但这里有一些问题:
就其本身而言,这些通常可能不会破坏交易。但是您需要有效地反转与用户不匹配的条件数据包和块数据包。我怀疑这将足以破坏协议处理,以至于简单的尝试都会失败。
我想说,将您知道将具有用户关联的端口 80 输出转发到单独的链,然后按用户仅过滤该链。这应该足以破坏其他用户的流量,但不会破坏内部流量,从而总体上满足您的要求。
If you mean "a local user with a discrete uid" then you can use the owner module (
-m owner
) and the--uid-owner #
option.But there are some problems here:
By themselves, those might not normally be deal-breakers. But you need to effectively invert the conditional and block packets not matching the user. I suspect this will sufficiently break protocol processing that a simple attempt to do this will fail.
I would say, forward port 80 output that you know will have a user association to a separate chain, and then filter only that chain by user. This should sufficiently break other user's traffic but not internal traffic to generally meet your requirement.
iptables 有
-mowner --uid-owner ###
匹配,“如果数据包是由具有给定有效用户 ID 的进程创建的,则匹配”iptables has the
-m owner --uid-owner ###
match which "Matches if the packet was created by a process with the given effective user id"