小编Nic*_*uti的帖子

限制特定用户访问本地端口

我试图限制我的 Debian 上特定用户对特定端口的访问。

假设用户的 id 是 1000,我想阻止的端口是 5000。

我尝试通过以下命令使用 iptables:

iptables -I OUTPUT -o lo -p tcp --dport 5000 --match owner --uid-owner 1000 -j DROP
Run Code Online (Sandbox Code Playgroud)

如果用户执行curl 127.0.0.1:5000curl <machine_ip>:5000不执行,它会起作用curl localhost:5000

我不明白为什么它不起作用。我虽然localhost被转换为127.0.0.1. 有什么不同 ?

在我的 /etc/hosts 文件中,我有

127.0.0.1   localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost   ip6-localhost ip6-loopback
Run Code Online (Sandbox Code Playgroud)

networking security firewall iptables access-control

7
推荐指数
1
解决办法
2768
查看次数