Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a strange behaviour of iptables that I cannot explain or understand.

I have a user test which has its primary group test. I want to block any network access from this user.

Now, if I say

iptables -A OUTPUT -o eth0 -m owner --uid-owner test -j DROP

and I su test and then I get the following:

ping       # WORKS
nmap -sP   # fails
wget       # fails

However, if I flush the iptables again, and say instead:

iptables -A OUTPUT -o eth0 -m owner --gid-owner test -j DROP

(notice the difference: gid instead of uid) then I get the following

ping       # fails
nmap -sP   # fails
wget       # fails

So as you can see, the rule seems to match both times, but only when I block the primary group also ICMP is blocked. Is this a bug or does this make some sense that I am unaware of?

I mean I could simply block both and be happy, but I want to understand why they behave differently.

My iptables version is v1.4.4.

share|improve this question
up vote 3 down vote accepted

Generation of icmp requires raw access to a socket which in turn requires root access. Ping therefore runs suid, so the uid for the owner of the socket is root and not test.

share|improve this answer
Ah! That actually makes a lot of sense, thank you. – bitmask Apr 30 '11 at 15:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.