Gentoo Archives: gentoo-user

From: Grant Taylor <gtaylor@×××××××××××××××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: How to hide a network interface from an application
Date: Sat, 15 Aug 2020 18:22:19
Message-Id: b6be8cc5-895f-e055-40d0-a7a42e9c617f@spamtrap.tnetconsulting.net
In Reply to: Re: [gentoo-user] Re: How to hide a network interface from an application by Alexey Mishustin
1 On 8/13/20 6:03 PM, Alexey Mishustin wrote:
2 > Isn't this classic option suitable?
3 >
4 > iptables -A OUTPUT -i <some_interface> -m owner --gid-owner noinet -j DROP
5
6 Ugh.
7
8 I'm sure that's a viable method to deal with the problem after the fact.
9
10 But I prefer to not have the problem in the first place. Thus no need
11 to deal with it after the fact.
12
13 I dislike Docker, but I do like the idea of containers or network
14 namespaces. As such, I think it should be relatively trivial to create
15 a network namespace that has what you need without too much effort. I'd
16 think that some judicious "unshare" / "nsenter" / "ip netns exec"
17 commands would suffice.
18
19 I run BIRD in multiple network namespaces (think virtual routers) for
20 things with a few commands and NO Docker, et al.
21
22 unshare --mount=/run/mountns/${NetNS} --net=/run/netns/${NetNS}
23 --uts=/run/utsns/${NetNS} /bin/hostname ${NetNS}
24 nsenter --mount=/run/mountns/${NetNS} --net=/run/netns/${NetNS}
25 --uts=/run/utsns/${NetNS} /bin/ip link set dev lo up
26 nsenter --mount=/run/mountns/${NetNS} --net=/run/netns/${NetNS}
27 --uts=/run/utsns/${NetNS} /usr/sbin/bird -P /var/run/bird.${NetNS}.pid
28 -s /var/run/bird.${NetNS}.ctl
29
30 You can replace /usr/bin/bird ... with whatever command you need to
31 start Plex.
32
33 Obviously you will need to add the network interface to connect from
34 your physical network to the network namespace and configure it
35 accordingly. But that's relatively trivial to do.
36
37 I find these types of network / mount / UTS namespaces, containers, to
38 be extremely lightweight and easy to do things in. I've created some
39 wrapper scripts to make it trivial to add / list / remove such
40 containers; mknns, lsnns, rmnns.
41
42
43
44 --
45 Grant. . . .
46 unix || die

Replies

Subject Author
Re: [gentoo-user] Re: How to hide a network interface from an application Neil Bothwick <neil@××××××××××.uk>