如何在具有4个绑定NIC的主机上将LXD容器桥接到VLAN接口

时间:2019-04-15 20:34:00

标签: networking lxc vlan lxd

这是我的情况。我的主机有4个绑定的网卡(bond0)。我想使用不同的VLAN来使用不同的容器。这是我的主机接口文件:

source /etc/network/interfaces.d/*

######################
# Loopback interface #
######################

auto lo
iface lo inet loopback

#######################
# Physical Interfaces #
#######################

auto eno1
iface eno1 inet manual
        bond-master bond0
        bond-primary eno1

auto eno2
iface eno2 inet manual
        bond-master bond0

auto eno3
iface eno3 inet manual
        bond-master bond0

auto eno4
iface eno4 inet manual
        bond-master bond0


##########################
# BONDED NETWORK DEVICES #
##########################

auto bond0
iface bond0 inet manual
        bond-mode 4
        bond-slaves none
        bond-miimon 100
        bond-lacp-rate 1
        bond-slaves eno1 eno2 eno3 eno4
        bond-downdelay 200
        bond-updelay 200
        bond-xmit-hash-policy layer2+3


####################
# RAW VLAN DEVICES #
####################

iface bond0.100 inet static
vlan-raw-device bond0

iface bond0.101 inet static
vlan-raw-device bond0

iface bond0.102 inet static
vlan-raw-device bond0

iface bond0.103 inet static
vlan-raw-device bond0


##########################
# BRIDGE NETWORK DEVICES #
##########################

auto br0
iface br0 inet static
bridge_ports bond0
bridge_maxwait 10
address 10.9.0.188
netmask 255.255.0.0
broadcast 10.9.255.255
network 10.9.0.0
gateway 10.9.0.1
dns-nameservers 10.1.1.84 8.8.8.8

auto br0-100
iface br0-100 inet manual
    bridge_ports bond0.100
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

auto br0-101
iface br0-101 inet manual
    bridge_ports bond0.101
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

auto br0-102
iface br0-102 inet manual
    bridge_ports bond0.102
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

auto br0-103
iface br0-103 inet manual
    bridge_ports bond0.103
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

我已为容器创建配置文件以使用vlan100(br0-100)

config: {}
description: ""
devices:
  eth0:
    nictype: bridged
    parent: br0-100
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: vlantest
used_by:
- /1.0/containers/v100

容器中的接口文件:

source /etc/network/interfaces.d/*.cfg

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
  address 10.9.100.101
  netmask 255.255.255.0
  network 10.9.100.0
  gateway 10.9.100.1
  broadcast 10.9.100.255
  dns-nameservers 10.1.1.84

容器中的ifconfig:

eth0      Link encap:Ethernet  HWaddr 00:16:3e:40:16:9c 
          inet6 addr: fe80::216:3eff:fe40:169c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1016 (1.0 KB)  TX bytes:1192 (1.1 KB)

eth1      Link encap:Ethernet  HWaddr 00:16:3e:42:12:66 
          inet6 addr: fe80::216:3eff:fe42:1266/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1700 (1.7 KB)  TX bytes:508 (508.0 B)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

我在这里做错了什么?容器出于某种原因(eth1)创建了一个附加接口,但是都没有获取地址。

0 个答案:

没有答案