jwb*_*ley 3 debian vlan bridge kvm-virtualization
我正在将 Debian Squeeze 框设置为 KVM 主机。我想为每个 KVM 来宾添加多个接口,因此我希望它们位于不同的 VLAN 上。
读完之后,我认为最好的方法是将多个逻辑 VLAN(子)接口添加到物理网卡,然后为每个 VLAN 接口创建一个网桥适配器,并将每个网桥分配为 KVM 来宾的网卡。这是有道理的,还是疯狂的?
我必须像这样在 KVM 上使用桥接接口吗?我不能将 eth1.xx 和 eth1.yy 添加到下面的接口配置中,然后将它们直接配置为桥接 KVM 来宾 NIC 吗?如果是这样,这在下面的接口配置文件中应该如何显示?
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
Run Code Online (Sandbox Code Playgroud)
更新
如果有人能为我澄清配置,我真的很喜欢它,因为我也看到上面配置了这种语法,所以我不明白为什么一个比另一个更受欢迎;
# 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
Run Code Online (Sandbox Code Playgroud)
回答
我在拓扑上同意 dyasny,并且很高兴使用以下配置与类似于 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
Run Code Online (Sandbox Code Playgroud)
我对 Debian 配置不太熟悉,但你描述的是正确的
eth0 -> eth0.100 -> brvlan100 <-- 虚拟机
这是设置它的方法。对于一个虚拟机,这可能看起来很混乱,但是对于数百个虚拟机,您会看到这样做的好处。
如果您想避免这样做,您可能需要在虚拟机内部设置标签,只要网桥连接到中继端口,这也可以工作
小智 5
据我了解 Debian 网络配置基础设施,使用brX.YYY
不应该工作,因为它会在网桥“上方”创建一个 VLAN 伪接口,对它的支持刚刚开始添加到内核中:https : //lwn.net/Articles/ 513710/
这是我使用的配置类型:
# 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
...
Run Code Online (Sandbox Code Playgroud)
如果要使用聚合/绑定接口:
bridge_ports