Debian:我应该将vlan接口添加到KVM的网桥吗?

我正在设置一个Debian Squeeze框作为KVM主机。 我想为每个KVM来宾添加多个接口,所以我希望它们位于不同的VLAN上。

读完这个之后,我认为最好的方法是在物理网卡上添加多个逻辑VLAN(子)接口,然后为每个VLAN接口创build一个网适配器,并将每个网桥分配为KVM访客的网卡。 这是否合理,或疯狂?

我必须像这样使用KVM的桥接接口吗? 我不能只将eth1.xx和eth1.yy添加到下面的接口configuration中,然后将它们直接configuration为桥接KVM访客网卡? 如果是这样的话,应该如何查看下面的接口configuration文件?

user@host:~$ cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # Management Interface auto eth0 iface eth0 inet static address 172.22.0.31 netmask 255.255.255.0 gateway 172.22.0.1 # Interface for guest VMs auto eth1 # Guest1 : Use VLAN 117 auto eth1.117 iface eth1.117 inet manual # Set up br1 for guest 1, bridging with vlan 117 auto br1.117 iface br1.117 inet manual bridge_ports eth1.117 bridge_stp off user@host:~$ uname -a Linux hostname 3.4.9 #1 SMP Wed Aug 22 19:08:46 BST 2012 x86_64 GNU/Linux 

UPDATE

我真的很喜欢,如果有人可以为我澄清configuration,因为我也看到上面configuration了这个语法,所以我不明白为什么一个会比另一个更喜欢;

 # Interface for guest VMs auto eth1 allow-hotplug eth1 iface eth1 inet static # Vlan 117 for guest 1 auto vlan 117 iface vlan111 inet static vlan_raw_device eth1 # Guest 1 : NIC 1 auto br1.117 iface br1.117 inet manual bridge_ports vlan117 bridge_stp off 

回答

我同意dyasny的拓扑结构,我很高兴地使用下面的configuration与Silopolis的例子类似:

 # Mangement Interafce allow-hotplug eth0 # Guest Interface allow-hotplug eth1 # Guest 1 allow-hotplug vlan116 # Guest 2 allow-hotplug vlan117 # Management auto eth0 iface eth0 inet static address 10.0.0.10 netmask 255.255.255.0 gateway 10.0.0.1 # Guest 1 auto vlan116 iface vlan116 inet manual vlan_raw_device eth1 # Guest 2 auto vlan117 iface vlan117 inet manual vlan_raw_device eth1 allow-hotplug br116 allow-hotplug br117 # Guest 1 auto br116 iface br116 inet manual bridge_ports vlan116 bridge_stp off # Guest 2 auto br117 iface br117 inet manual bridge_ports vlan117 bridge_stp off 

据我了解的Debiannetworkingconfiguration基础设施,使用brX.YYY不应该工作,因为它会创build一个VLAN虚拟接口“之上”的桥梁,刚刚开始添加到内核的支持: https : //lwn.net /条/ 513710 /

这里是我使用的configurationtypes:

 # Bring up physical interface iface eth0 inet manual # Create VLAN interfaces iface eth0.10 inet manual vlan_raw_device eth0 iface eth0.20 inet manual ... # Create bridges auto vmbr10 iface vmbr10 inet static address 10.10.10.81 netmask 255.255.255.0 #gateway 10.10.10.254 bridge_ports eth0.10 bridge_stp off bridge_fd 0 auto vmbr20 iface vmbr20 inet static address 10.10.20.81 ... 

如果你想使用agregated / bonded接口:

  • 绑定物理接口
  • 在bondX接口上创buildVLAN接口(bondX.YYY)
  • 使用bondX.YYY作为bridge_ports

我不太熟悉Debian的configuration,但是你描述的是正确的

eth0 – > eth0.100 – > brvlan100 < – VM

这是设置的方法。 对于一个虚拟机来说,这可能看起来很混乱,但有数百个虚拟机,你会看到这样做的好处。

如果您想避免这样做,您可能需要在虚拟机内部设置标签,只要网桥连接到一个中继端口