How do containers tie to multiple IP's on a NIC?

Daniel Lezcano daniel.lezcano at free.fr
Sun Jul 4 12:49:31 PDT 2010


On 07/04/2010 09:18 PM, Whit Blauvelt wrote:
> On Sun, Jul 04, 2010 at 06:51:34PM +0200, Daniel Lezcano wrote:
>
>    
>> What container userspace command are you using ? libvirt ? liblxc ?
>> unshare --net ?
>>      
> Which one do you recommend, considering what I'm trying to do with multiple
> IPs on a NIC? I haven't committed to one yet. Which utility do you expect
> future development will favor most? I'll be happy to use any tool which gets
> the job done, preferably one that has a future.
>    

Well  ... please don't consider what I will suggest as "preaching for 
its parish" ;)
(not sure it is a correct expression. It is a direct translation from 
French)

I would recommend to use the lxc tools, preferably the 0.7.1 version. 
These tools allow to do what you are expecting that is assign several Ip 
addresses to the same virtual nic.

They are available at:

http://lxc.sourceforge.net/download/lxc/lxc-0.7.1.tar.gz

an older version is certainly available on your distro.

As a quick start:

write a configuration file (eg. lxc.conf)

lxc.network.type=macvlan
lxc.network.link=eth0
lxc.network.flags=up
lxc.network.ipv4=1.2.3.4/24
lxc.network.ipv4=192.168.1.123/24
lxc.network.ipv4=10.0.0.23
lxc.network.ipv4=172.2.1.3

And then lxc-execute -n foo -f lxc.conf /bin/bash

In your shell you should have a new network with one interface and 
several IP addresses.

You can create much more complex configuration but I let you check if 
these tools fit your needs.

Thanks
   -- Daniel



More information about the Containers mailing list