Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: How to hide a network interface from an application
Date: Fri, 14 Aug 2020 20:03:40
Message-Id: rh6qmg$phq$1@ciao.gmane.io
In Reply to: Re: [gentoo-user] Re: How to hide a network interface from an application by Alexey Mishustin
1 On 2020-08-14, Alexey Mishustin <shumkar@×××××××.ru> wrote:
2
3 > Isn't this classic option suitable?
4 >
5 > groupadd noinet
6 > usermod -a -G noinet <your_user>
7 > iptables -A OUTPUT -i <some_interface> -m owner --gid-owner noinet -j DROP
8 > and calling not
9 > Plex
10 > but
11 > sg noinet Plex
12 > (or whatever name the binary has)
13
14 Thanks for the suggestion!
15
16 [For posterity's sake, with -A Output it's -o <interface> rather than
17 -i <interface>]
18
19 Yes, I think that should work. I had forgotten (or never knew?) that
20 iptables rules could trigger on the uid or gid of the process that
21 sent the packet. The Plex media server already runs in its own
22 user/group -- something I should have mentioned in my original post,
23 since it means that "from a user" instead of "from an application"
24 would also work. My original post also said I was trying to hide an
25 interface, when all I really needed was to prevent sending of packets
26 on that interface.
27
28 I think this should work, but I need to rebuild my kernel with the
29 iptables "owner" extension enabled:
30
31 iptables -A OUTPUT -o <interface> -m owner --uid-owner plex -j DROP
32
33 I was just about to start experimenting with ipvlan and network
34 namespaces, but an iptables rule triggering on uid looks much much
35 easier.
36
37 --
38 Grant

Replies

Subject Author
Re: [gentoo-user] Re: How to hide a network interface from an application Alexey Mishustin <shumkar@×××××××.ru>
[gentoo-user] Re: How to hide a network interface from an application Grant Edwards <grant.b.edwards@×××××.com>