I am trying to disable access to IP 1.2.3.4 for all users except members of the "neta" group. This is a new group that I created just for that.
iptables -I OUTPUT -o eth0 -p tcp -d 1.2.3.4 -m owner ! --gid-owner neta -j REJECT
This disables access to 1.2.3.4 for all users, even if they are members of the "neta" group.
I have user xx and he is a member of the xx groups (main group) and neta. If I changed the rule to:
iptables -I OUTPUT -o eth0 -p tcp -d 1.2.3.4 -m owner \! --gid-owner xx -j REJECT
all but user xx cannot access 1.2.3.4.
I added root to this xx group:
usermod -a -G xx root
but root was still unable to access this IP address. If I add the main user group (root, xx) to the rule, everything will work as expected.
I tried to split it into two rules to be sure (and the log is rejected):
iptables -A OUTPUT -o eth0 -p tcp -d 1.2.3.4 -m owner --gid-owner neta -j ACCEPT iptables -A OUTPUT -o eth0 -p tcp -d 1.2.3.4 -m limit --limit 2/s --limit-burst 10 -j LOG iptables -A OUTPUT -o eth0 -p tcp -d 1.2.3.4 -j REJECT
but there is no difference. Everything is rejected.
There are no other iptables rules.
root@vm1 :~
I want to (allow) access to this IP by adding / removing users from this "neta" group instead of adding iptables rules for each user.
source share