Re: [vserver] vserver and network namespace support

From: Adrian Reyer <are_at_lihas.de>
Date: Fri 09 May 2014 - 19:54:04 BST
Message-ID: <20140509185404.GA4122@r2d2.s.lihas.de>

On Fri, May 09, 2014 at 05:17:18PM +0200, Thomas Weber wrote:
> Is anyone successfully using vserver with network namespaces and "stock"
> util-vserver? The comments from Herbert and Daniel seem to imply that
> this is possible - but I have yet to see a working configuration.
> Kernel: 3.10.38-vs2.3.6.8
> util-vserver: 0.30.216-pre3062

util-vserver 0.30.216-pre3054-1 and kernel 3.10.38-vs2.3.6.8+lihas1
here on debian sid (my laptop):

VSNAME=vsnetns
IFACE=br1
IP=192.168.5.244
BROADCAST=192.168.5.255
GATEWAY=192.168.5.254
NETMASK=255.255.255.0
DNSSERVER=192.168.5.254
MASKBIT=24
CONTEXT=244
MIRROR="http://de.archive.ubuntu.com/ubuntu"

vserver $VSNAME build -m debootstrap --context $CONTEXT --hostname $VSNAME --interface $VSNAME=$IFACE:$IP/$MASKBIT --initstyle plain -- -m $MIRROR -d raring -- --arch i386
echo plain > /etc/vservers/$VSNAME/apps/init/style
cat <<EOF >>/etc/vservers/$VSNAME/fstab
none /run tmpfs size=16m,nosuid,mode=0755 0 0
EOF
echo $VSNAME > /etc/vservers/$VSNAME/vdir/etc/hostname
# Network Namespace, proprietary Software after all
VS=$VSNAME
CONTEXT=$(cat /etc/vservers/${VS}/context)
grep -q NET_ADMIN /etc/vservers/$VS/bcapabilities || echo NET_ADMIN >> /etc/vservers/$VS/bcapabilities
grep -q NET_RAW /etc/vservers/$VS/bcapabilities || echo NET_RAW >> /etc/vservers/$VS/bcapabilities
mkdir -p /etc/vservers/$VS/apps/init
echo 'plain' > /etc/vservers/$VS/apps/init/style
touch /etc/vservers/$VS/noncontext
mkdir -p /etc/vservers/$VS/netns/interfaces/0
echo v${CONTEXT} > /etc/vservers/$VS/netns/name
echo v${CONTEXT}a > /etc/vservers/$VS/netns/interfaces/0/host
echo v${CONTEXT}b > /etc/vservers/$VS/netns/interfaces/0/guest
echo veth > /etc/vservers/$VS/netns/interfaces/0/type
rm -rf /etc/vservers/$VS/interfaces/0
mkdir -p /etc/vservers/$VS/scripts
cat <<EOF >/etc/vservers/$VS/scripts/pre-start
DONT_SKIP_DEFAULTS=1
brctl addif br1 v${CONTEXT}a
ip link set dev v${CONTEXT}a up
EOF

cat <<EOF >>/etc/vservers/$VSNAME/vdir/etc/network/interfaces
auto v${CONTEXT}b
iface v${CONTEXT}b inet static
    address $IP
    broadcast $BROADCAST
    netmask $NETMASK
    gateway $GATEWAY
    dns-nameservers $DNSSERVER
    
EOF

No dhcp worked for me, /proc/net won't be visible inside the vserver,
vprocunhide seems not to work, /proc/net is a symlink into the own pid

Regards,
        Adrian

-- 
LiHAS - Adrian Reyer - Hessenwiesenstra├če 10 - D-70565 Stuttgart
Fon: +49 (7 11) 78 28 50 90 - Fax:  +49 (7 11) 78 28 50 91
Mail: lihas_at_lihas.de - Web: http://lihas.de
Linux, Netzwerke, Consulting & Support - USt-ID: DE 227 816 626 Stuttgart
Received on Fri May 9 20:10:32 2014
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Fri 09 May 2014 - 20:10:32 BST by hypermail 2.1.8