CentOS 7 上的 KVM 服务器绑定 2 个 NIC 和桥接 VLAN 网络配置不起作用

CentOS 7 上的 KVM 服务器绑定 2 个 NIC 和桥接 VLAN 网络配置不起作用

我正在尝试在服务器上设置 CentOS 7 以通过 KVM 托管虚拟机。我尝试设置的网络应允许通过绑定/桥接设置在两个 NIC 上建立多个 VLAN。它根本不起作用。我不知道我做错了什么。有人能给我指出正确的方向吗?

绑定配置文件

alias bond0 bonding
options bond0 miimon=100 mode=4 lacp_rate=1

bond0.conf

alias bond0 bonding
options bond0 miimon=100 mode=4 lacp_rate=1

DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback

ifcfg-bond0

# Use tagged VLANs
ARP=no
BOOTPROTO=none
DEVICE=bond0
IPV6INIT=no
## Optional, use for jumbo frames if needed
#MTU=9000
NM_CONTROLLED=yes
NOZEROCONF=yes
ONBOOT=yes
BONDING_MASTER=yes
BONDING_OPTS="mode=4 miimon=100 updelay=30000"

ifcfg-bond0.341

DEVICE=bond0.341
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
VLAN=yes
BRIDGE=br341
NM_CONTROLLED=yes

ifcfg-bond0.342

DEVICE=bond0.342
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
VLAN=yes
BRIDGE=br342
NM_CONTROLLED=yes

ifcfg-bond0.400

DEVICE=bond0.400
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
VLAN=yes
BRIDGE=br400
NM_CONTROLLED=yes

ifcfg-bond0.450

DEVICE=bond0.450
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
VLAN=yes
BRIDGE=br450
NM_CONTROLLED=yes

ifcfg-br341

NM_CONTROLLED=yes
DEVICE=br341
ONBOOT=yes
TYPE=Bridge
VLAN=yes
# IPv4
DNS1=192.168.36.3
DNS2=192.168.100.3
DNS3=192.168.160.10
NOZEROCONF=yes
STP=yes
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="Bridge br341"
BRIDGING_OPTS=priority=32768
IPADDR=192.168.34.21
PREFIX=26
GATEWAY=192.168.34.1
NETWORK=192.168.34.0

ifcfg-br342

NM_CONTROLLED=yes
DEVICE=br342
ONBOOT=yes
TYPE=Bridge
VLAN=yes
# IPv4
DNS1=192.168.36.3
DNS2=192.168.100.3
DNS3=192.168.160.10
NOZEROCONF=yes
STP=yes
BRIDGING_OPTS=priority=32768
BOOTPROTO=none
IPADDR=192.168.34.86
GATEWAY=192.168.34.65
NETWORK=192.168.34.64
PREFIX=26
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME="Bridge br342"

ifcfg-br400

NM_CONTROLLED=yes
DEVICE=br400
ONBOOT=yes
TYPE=Bridge
VLAN=yes
# IPv4
DNS1=192.168.36.3
DNS2=192.168.100.3
DNS3=192.168.160.10
NOZEROCONF=yes
STP=yes
BRIDGING_OPTS=priority=32768
BOOTPROTO=none
IPADDR=192.168.43.21
GATEWAY=192.168.43.1
NETWORK=192.168.43.0
PREFIX=26
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="Bridge br400"

ifcfg-br450

NM_CONTROLLED=yes
DEVICE=br450
ONBOOT=yes
TYPE=Bridge
VLAN=yes
# IPv4
DNS1=192.168.36.3
DNS2=192.168.100.3
DNS3=192.168.160.10
NOZEROCONF=yes
STP=yes
BOOTPROTO=none
IPADDR=192.168.34.150
GATEWAY=192.168.34.129
NETWORK=192.168.34.128
PREFIX=26
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="Bridge br450"

ifcfg-em1

TYPE=Ethernet
DEVICE=em1
ONBOOT=yes
MASTER=bond0
NOZEROCONF=yes
ONBOOT=yes
SLAVE=yes
NAME="System em1"
NM_CONTROLLED="yes"

ifcfg-em1.341

DEVICE=em1.341
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond0.341
NM_CONTROLLED=yes

ifcfg-em1.342

DEVICE=em1.342
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond0.342
NM_CONTROLLED=yes

ifcfg-em1.400

DEVICE=em1.342
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond0.342
NM_CONTROLLED=yes

ifcfg-em1.450

DEVICE=em1.450
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond0.450
NM_CONTROLLED=yes

ifcfg-em2

NM_CONTROLLED="yes"
DEVICE=em2
ONBOOT=yes
MASTER=bond0
NOZEROCONF=yes
ONBOOT=yes
SLAVE=yes
TYPE=Ethernet
NAME="System em2"

ifcfg-em2.341

DEVICE=em2.341
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond0.341
NM_CONTROLLED=yes

ifcfg-em2.342

DEVICE=em2.342
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond0.342
NM_CONTROLLED=yes

ifcfg-em2.400

DEVICE=em2.400
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond0.400
NM_CONTROLLED=yes

ifcfg-em2.450

DEVICE=em2.450
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond0.450
NM_CONTROLLED=yes

答案1

总结我的评论:

  • VLAN 标记发生在绑定接口上。应删除 ifcfg-em*.*
  • 应该设置 NM_CONTROLLED=no(不希望 NM 搞乱事情)
  • 在这个带有网桥的虚拟机网络场景中,STP 通常是禁用的
  • 桥接接口上的 VLAN=yes 可能不正确

相关内容