Subject: Re: [vserver] Too many network devices inside guest?
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Fri, 30 Oct 2009 18:53:04 +0100

On Fri, Oct 30, 2009 at 03:18:39PM +0100, Gerhard Mehsel wrote:
> Hello,

> I just set up a Debian Lenny Vserver and tried to customize my

please avoid the 2.6.26 kernels, they are known-to-be-broken

> network. My Problem is, that I configured 3 network devs, but now
> inside the vserver appear five devices?

that sounds interesting, but surely the host has more than
3 network devices configured, yes?

> Is there a small tutorial what to set to get 2 IP adresses and a 
> loopback device inside a verserver guest?

simply assign them to the guest (via config) and be done

> Do the devices have to be configured in the host, also?

yes, Linux-VServer uses IP isolation not network virtualization,
so all the network setup happens on the host, the guest is
just assigned a subset of the available IPs which it then
can use to bind to ...

> On the host system I have mutliple IP Adresses on one device 
> with some aliases:

that's fine, although aliases are not required nowadays

> /etc/network/interfaces:
> 
> eth0
> ....
> eth0:0
> ....
> eth0:1
> ....
> eth0:2
> ....
> eth0:3
> ....
> eth0:4
> ....

> in /etc/vservers/$VSERVER/interfaces/{0 1 2}
> 0/dev: eth0
> 1/dev: eth0:1
	 ~~~~~~ that's wrong, the device is still eth0
> 2/dev: lo
         ~~~ that's usually wrong too, unless you really
	     want util-vserver to create IPs on lo

note: specifying a dev entry means that util-vserver
will add that IP (on the host) to the given device
on guest startup

> 0/ip: 192.168.1.10
> 1/ip: 192.168.1.11
> 2/ip: 127.0.0.1

you usually do not specify 127.0.0.1 for a guest,
unless you exactly know what you are doing :)

you are also missing the netmask/prefix for your
interfaces ...

> After booting the vserver guest ifconfig displays 5 devices:
> -----------------------------------------
> 
> eth0      Link encap:Ethernet  HWaddr xxxx
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:858628 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:1302041 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:220101426 (209.9 MiB)  TX bytes:1809823317 (1.6 GiB)
>           Interrupt:19 Base address:0xa400
> 
> eth0:0    Link encap:Ethernet  HWaddr xxxx
>           inet addr:192.168.1.10 ...
> 
> eth0:1    Link encap:Ethernet  HWaddr xxxx
>           inet addr:192.168.1.11 ...
> 
> eth0:3    Link encap:Ethernet  HWaddr xxxx
>           inet addr:192.168.1.10  ...
> 
> eth0:4    Link encap:Ethernet  HWaddr xxxx
>           inet addr:192.168.1.11 ...

which is not surprising, as you add the already
existing IPs again with the wrong netmask
(the part you removed :)

> lo        Link encap:Local Loopback
>           inet addr:127.0.0.1  Mask:255.0.0.0
>           UP LOOPBACK RUNNING  MTU:16436  Metric:1
>           RX packets:5669 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:5669 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:1482322 (1.4 MiB)  TX bytes:1482322 (1.4 MiB)
> --------------------------------------------------------

> Is this a mixture between the configured devices from Host and Guest
> system?

no, it is actually all interfaces (from the host)
carrying an IP 'given' to the guest

> How do I do this correctly?

either let util-vserver configure the guest IPs
on the host (dev entry) or put a 'nodev' entry
in the config, so that the guest uses the pre-
configured IPs 

best,
Herbert

> Thanks a lot,
> Gerd