通过一个lxc容器在主机上使用别名绑定接口

如标题所示,如何编辑lxc容器的configuration以使用主机上的别名bond0接口? 这就是我现在在/ etc / network / interfaces文件中的内容:

# 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 

我可以添加到最后:

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

并使lxc容器使用这个地址? 我不想桥接,我只想要主机和lxc继续。 在同一个networking上。 我不知道什么configuration选项进入/ var / lib / lxc / lxc_cont / config文件。 我试过这个

 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 

但得到这个错误:

 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 

在将来,我将在bond0接口上添加其他容器,例如:

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

我之前已经使用桥接接口来设置容器,但是我被卡住了。

任何帮助或指针非常感谢!

谢谢你的时间!

PS在我看来,我的问题是类似于这一个

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

得到了一位同事pipe理员的帮助。 这是工作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 

所以你需要将IP地址移动到网桥。 lxc-config看起来像这样:

 ... 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 ... 

我通常也编辑客人的接口文件,虽然这应该不需要,因为上面的configuration控制IP分配:

 # 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 

所以现在主机和未来客户lxc包含器将驻留在同一个networking上。 对于其他lxc包含器,只需在子网中分配下一个ip即可。 我想你不需要macvlans,我尝试使用这些,但不能得到它的工作。

希望有人会发现这个有用的,如果他们这样做,我会把这个标记为接受的答案。

如果我错过了一些信息,请让我知道。