Gentoo Archives: gentoo-user

From: "Róbert Čerňanský" <openhs@×××××××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Managing network interface in a namespace
Date: Fri, 18 Nov 2016 19:42:07
Message-Id: 20161118204151.54596ce8.openhs@tightmail.com
1 Hi all,
2
3 I would like to bring up and configure a network interface which
4 exists in a (network) namespace. I would like to use standard OpenRC
5 'net.<iface>' init script to do so.
6
7 Since the interface (veth1) exists only in a namespace (myns) I need
8 that the init script would be executed within that namespace:
9
10 ip netns exec myns /etc/init.d/net.veth1 start|stop|...
11
12 While I can do that manually as above the automatic run (during boot)
13 is however executed in the global namespace.
14
15 My current, not very good approach is that I've created a wrapper around
16 runscript and created a copy of /etc/init.d/net.lo
17 to /etc/init.d/net.veth1 where I've changed the first line to that
18 wrapper. It does work when invoking the script manually but it is not
19 executed by OpenRC at all during boot or when I type 'rc' even if
20 net.veth1 is included in default runlevel. Also, to have a copy of init
21 script is not very nice. Therefore I'm seeking other solutions. Is
22 there any way to tell OpenRC that it should configure an interface
23 in a specific namespace?
24
25 The wrapper script for curious:
26
27 #!/bin/sh
28 namespace=${1}
29 shift
30 /bin/ip netns exec ${namespace} /sbin/runscript ${@}
31
32 First line of /etc/init.d/net.veth1 then looks like this:
33
34 #!/usr/local/bin/runscript-netns myns
35
36 Robert
37
38
39 --
40 Róbert Čerňanský
41 E-mail: openhs@×××××××××.com
42 Jabber: hs@××××××.sk