Networking

CentOS 7 上的 KVM 伺服器綁定 2 個 NIC 和橋接 vlan 網路配置不起作用

  • August 9, 2017

我正在嘗試在伺服器上設置 CentOS 7 以通過 KVM 託管 VM。我嘗試設置的網路應該允許通過綁定/橋設置跨兩個 NIC 的多個 vlan。它根本不起作用。我無法弄清楚我做錯了什麼。有人可以指出我正確的方向嗎?

綁定.conf

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

債券0.conf

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

ifcfg-lo

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-債券0

# 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

總結我的評論:

  • vlan 標記發生在綁定介面。ifcfg-em*.* 應該被刪除
  • NM_CONTROLLED=no 應該設置(不希望 NM 弄髒東西)
  • 在此帶有網橋方案的 VM 網路中,通常禁用 STP
  • 網橋介面上的 VLAN=yes 可能不正確

引用自:https://serverfault.com/questions/867389