1

As the title says, how do I edit the lxc container's configuration to use the aliased bond0 interface on the host? This is what I have in the /etc/network/interfaces file now:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet static
#   address 192.168.100.90/22
#   gateway 192.168.101.1


auto bond0
iface bond0 inet static
    address 192.168.100.90/22
    gateway 192.168.101.1
    bond-slaves eth0 eth1
    bond-mode active-backup
    bond-miimon 100
    bond-primary eth0 eth1

Can I add this to at the end:

auto bond0:101
iface bond0:101 inet static
    address 192.168.100.101
    netmask 255.255.252.0

and make the lxc container use this address? I don't want bridging, I just want the host and lxc cont. on the same network. I don't know what configuration options go into /var/lib/lxc/lxc_cont/config file. I tried this

lxc.network.type = phys
lxc.network.flags = up
lxc.network.link = bond0:101
lxc.network.hwaddr = 00:00:00:fe:fe:01
lxc.network.ipv4 = 192.168.100.101/22
lxc.network.ipv4.gateway = 192.168.101.1

but get this error:

lxc-start 20160912185144.642 ERROR    lxc_conf - conf.c:lxc_assign_network:3044 - failed to move 'bond0:101' to the container : Invalid argument
      lxc-start 20160912185144.642 ERROR    lxc_start - start.c:lxc_spawn:1197 - failed to create the configured network

In the future I would be adding other containers on the bond0 interface such as:

auto bond0:102
iface bond0:102 inet static
    address 192.168.100.102
    netmask 255.255.252.0

auto bond0:102

etc.

I've setup containers using bridged interface before, but I'm stuck whith regards to this bonding thing.

Any help or pointers are much appreciated!

Thanks for your time!

P.S. seems to me that my question is similar to this one

https://serverfault.com/questions/744443/is-there-a-way-to-get-the-kvm-guest-using-alias-interfaces-to-communicate-with-o

antisa
  • 111
  • 2
  • I put an answer (using macvlan) but removed it, because I'm not sure how macvlan would cope with bonding. Anyway if you want to see how to have a guest appear on the physical net without having to set a bridge: http://www.pocketnix.org/posts/Linux%20Networking:%20MAC%20VLANs%20and%20Virtual%20Ethernets – A.B Sep 12 '16 at 17:24

1 Answers1

0

Had some help from a colleague admin at work. This is the working configuration:

# interfaces file

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet static
#   address 192.168.100.90/22
#   gateway 192.168.101.1

auto bond0
iface bond0 inet manual
    bond-slaves eth0 eth1
    bond-mode active-backup
    bond-miimon 100
    bond-primary eth0 eth1

auto br0
iface br0 inet static
    address 192.168.100.90
    netmask 255.255.252.0
    gateway 192.168.101.1
    bridge-ports bond0
    bridge-fd 0
    bridge-stp off
    bridge-maxwait 5

So you need to move the ip address to the bridge. lxc-config looks like this:

...
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.mtu = 1500
lxc.network.hwaddr = 00:00:00:fe:fe:01
lxc.network.ipv4 = 192.168.100.91/22
lxc.network.ipv4.gateway = 192.168.101.1
...

I usually edit the interfaces file for the guest also, although this shouldn't be needed as the config above controls the ip assignment:

# guest interfaces file
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.100.91
    netmask 255.255.252.0

So now the host machine and future guest lxc containters will reside on the same network. For the other lxc containter you simply assign the next ip in the subnet. I guess you don't need macvlans, I tried using those but couldn't get it to work.

Hope someone will find this usefull, if they do I'll mark this as accepted answer.

If I missed some information please let me know.

antisa
  • 111
  • 2