防止IPTables访问networking

我尝试使用此命令阻止用户sandbox访问networking

 $ iptables -A OUTPUT -m owner --uid-owner sandbox -j DROP 

但是,之后我仍然可以ping外部主机:

 $ sudo -u sandbox ping 206.190.36.45 PING 206.190.36.45 (206.190.36.45) 56(84) bytes of data. 64 bytes from 206.190.36.45: icmp_req=1 ttl=49 time=802 ms 64 bytes from 206.190.36.45: icmp_req=2 ttl=49 time=791 ms 

我究竟做错了什么?

更新

我的configuration如下所示:

 $ /sbin/iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination DROP all -- anywhere anywhere owner UID match sandbox 

更新

显然pingsetuid root集。 我只是要删除它:

 chmod us /bin/ping 

如果ping在您的系统上设置为root ,则它将打开从其发送ICMP回显请求的套接字。 因此这个规则永远不会匹配。

(请注意,在EL6,Debian squeeze等情况下都是如此。最近的发行版已经删除了ping的setuid位,并用一个function取代了它,在这种情况下,规则可能会匹配。

你确定你已经加载了nessesary的iptable模块吗?

尝试

 modprobe ipt_owner 

在控制台上。