0

Trying to disable the network access for the user:

[root@notebook ~]# iptables -I OUTPUT -m owner --uid-owner tempuser -j DROP
[root@notebook ~]# ip6tables -I OUTPUT -m owner --uid-owner tempuser -j DROP
Could not open socket to kernel: Address family not supported by protocol
[root@notebook ~]# 
[root@notebook ~]# iptables -I INPUT -m owner --uid-owner tempuser -j DROP
iptables: Invalid argument. Run `dmesg' for more information.
[root@notebook ~]# ip6tables -I INPUT -m owner --uid-owner tempuser -j DROP
Could not open socket to kernel: Address family not supported by protocol
[root@notebook ~]# 

Testing it:

[root@notebook ~]# su - tempuser
[tempuser@notebook ~]$ ping google.com
ping: unknown host google.com
[tempuser@notebook ~]$ 
[tempuser@notebook ~]$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=4.80 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=4.07 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1057ms
rtt min/avg/max/mdev = 4.071/4.439/4.807/0.368 ms
[tempuser@notebook ~]$ 
[tempuser@notebook ~]$ exit
logout
[root@notebook ~]# ping google.com
PING google.com (216.58.209.174) 56(84) bytes of data.
64 bytes from bud02s21-in-f14.1e100.net (216.58.209.174): icmp_seq=1 ttl=55 time=5.05 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 572ms
rtt min/avg/max/mdev = 5.059/5.059/5.059/0.000 ms
[root@notebook ~]# 

Question: how can I disable the network access for a given user under Linux? (INPUT/OUTPUT/IPv4/IPv6?) - why can I still ping IPv4 addresses with the user?

1 Answer 1

2

On some systems, ping is a SUID binary, because root privileges are required to send ICMP packets (on other systems I believe this is handled via capabilities).

[me@lory ~]$ ls -al /bin/ping
-rwsr-xr-x. 1 root root 40760 Sep 26  2013 /bin/ping

If you're on the former class of system, it's not tempuser who sends those PING packets; it's root. DNS lookups, which aren't done SUID, fail for tempuser (unknown host google.com), so you can confirm that your blocking is working.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .