我在创建 vlan 桥接时遇到问题。我为什么要这样做? - Kvm 需要桥接 - Vlan,因为我需要不同子网中的虚拟机 - 选项 active-backup 中的组队(小型 HA)
我在 centos 7 x64 上使用 NetworkManager 进行操作。两个物理接口:
TYPE=Ethernet
DEFROUTE=no
PEERDNS=no
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_PEERDNS=no
IPV6_PEERROUTES=no
IPV6_FAILURE_FATAL=no
NAME=enp8s0f0
UUID=311d4881-f3f1-45af-b01f-b48872b00b0f
ONBOOT=yes
TYPE=Ethernet
DEFROUTE=no
PEERDNS=no
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_PEERDNS=no
IPV6_PEERROUTES=no
IPV6_FAILURE_FATAL=no
NAME=enp8s0f1
UUID=eb43a315-b9e7-42fb-ab52-97e09a162825
ONBOOT=yes
我的步骤:
nmcli con add con-name team0 ifname team0 type team config '{"runner": {"name": "activebackup"}}'
nmcli con add con-name team0-port1 ifname enp8s0f0 type team-slave master team0
nmcli con add con-name team0-port2 ifname enp8s0f1 type team-slave master team0
nmcli con up team0-port2
nmcli con up team0-port1
之后我有:
NAME UUID TYPE DEVICE
virbr0 f8b30bd2-0d92-43af-9b3d-f68c63d6822b bridge virbr0
team0 19542d40-dce1-4328-9b64-f44f2fd7f1fb team team0
team0-port2 301b2003-18d0-4186-992a-fbc758bb1c7a 802-3-ethernet enp8s0f1
team0-port1 cafb8b30-60fc-475f-890d-0dc1191bc583 802-3-ethernet enp8s0f0
当我将 IP 分配给 team0 时,我可以从此接口网关 ping 通。接下来我创建 vlan 和网桥:
nmcli con add con-name vlan24-team0 type vlan id 24 dev team0
nmcli con add con-name br24 type bridge ifname vibr24 stp yes
nmcli con add con-name br24-vlan24 type bridge-slave ifname team0.24 master vibr24
nmcli con show
:
NAME UUID TYPE DEVICE
virbr0 f8b30bd2-0d92-43af-9b3d-f68c63d6822b bridge virbr0
team0 19542d40-dce1-4328-9b64-f44f2fd7f1fb team team0
enp8s0f0 311d4881-f3f1-45af-b01f-b48872b00b0f 802-3-ethernet --
enp8s0f1 eb43a315-b9e7-42fb-ab52-97e09a162825 802-3-ethernet --
br24-vlan24 16fd96b7-10b0-42b6-88e6-38749b33f816 802-3-ethernet --
br24 667cc267-3726-42cb-a5aa-0a2011167021 bridge vibr24
vlan24-team0 8ec83969-254b-4f75-8bad-983bac7e1af0 vlan team0.24
team0-port2 301b2003-18d0-4186-992a-fbc758bb1c7a 802-3-ethernet enp8s0f1
team0-port1 cafb8b30-60fc-475f-890d-0dc1191bc583 802-3-ethernet enp8s0f0
ip a
:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
6: enp8s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master team0 state UP qlen 1000
link/ether 00:1b:21:79:55:4f brd ff:ff:ff:ff:ff:ff
7: enp8s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master team0 state UP qlen 1000
link/ether 00:1b:21:79:55:4f brd ff:ff:ff:ff:ff:ff
8: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 00:1b:21:79:55:4f brd ff:ff:ff:ff:ff:ff
inet6 fe80::21b:21ff:fe79:554f/64 scope link
valid_lft forever preferred_lft forever
9: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
link/ether 66:0e:c8:c8:9c:37 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
10: team0.24@team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 00:1b:21:79:55:4f brd ff:ff:ff:ff:ff:ff
inet6 fe80::21b:21ff:fe79:554f/64 scope link
valid_lft forever preferred_lft forever
11: vibr24: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
link/ether ca:88:56:46:e5:18 brd ff:ff:ff:ff:ff:ff
nmcli con up br24-vlan24
Error: no device found for connection 'br24-vlan24'.
nmcli con up br24
Error: Device 'vibr24' is waiting for slaves before proceeding with activation.
组队工作正常,我认为将网桥映射到 vlan 存在问题,因为接口 vibr24 已关闭,并且 br24-vlan24 未映射到设备 vlan24-team0。但我第一次这样做,也许我错过了什么
VLAN=yes
TYPE=Vlan
PHYSDEV=team0
VLAN_ID=24
REORDER_HDR=0
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=vlan24-team0
UUID=8ec83969-254b-4f75-8bad-983bac7e1af0
ONBOOT=yes
TYPE=Ethernet
NAME=br24-vlan24
UUID=16fd96b7-10b0-42b6-88e6-38749b33f816
DEVICE=team0.24
ONBOOT=yes
BRIDGE=vibr24
DEVICE=vibr24
STP=yes
BRIDGING_OPTS=priority=32768
TYPE=Bridge
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=br24
UUID=667cc267-3726-42cb-a5aa-0a2011167021
ONBOOT=yes
在链接的另一个站点上,我有思科交换机并配置了带中继的端口通道。这些都是我所做的步骤,有人能帮我吗?
答案1
我不熟悉 NetworkManager。我个人更喜欢使用 iproute2/brctl/vconfig 工具的“老式”直接方法。但我发现了这个错误报告和勘误表:https://bugzilla.redhat.com/show_bug.cgi?id=1183420这些都和你的问题很相关。你只是在将 VLAN 添加到网桥而不是绑定接口时遇到了问题。但该错误报告中的解决方法也可以。
您不能添加br24-vlan24
(添加会失败,因为您已经有team0.24
与连接关联的设备vlan24-team
!),而是必须编辑vlan24-team0
属性以使其成为从属virb24
。
我尝试重现与您的配置类似的配置。但没有组合,因为似乎您没有遇到该部分的问题,因为您可以从 team0 进行 ping。我br24
在我的 NIC enp2s0 上创建了一个网桥和 vlan id 24。上面的链接建议修改绑定(在我们的例子中是 VLAN)连接,如下所示:
# nmcli c mod bond-bond0 connection.master br0
# nmcli c mod bond-bond0 connection.slave-type bridge
但这在 Linux Mint 上失败了,出现以下错误:
$ nmcli c mod vlan24-enp2s0 connection.master vibr24
Error: Failed to modify connection 'vlan24-enp2s0': connection.slave-type: Cannot set 'master' without 'slave-type'
$ nmcli c mod vlan24-enp2s0 connection.slave-type bridge
Error: Failed to modify connection 'vlan24-enp2s0': connection.master: Slave connections need a valid 'master' property
但在同一个命令中设置两个属性是有效的:
$ nmcli c mod vlan24-enp2s0 connection.slave-type bridge connection.master vibr24
$ nmcli con up br24
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/50)
$ nmcli con show
NAME UUID TYPE DEVICE
br24 502643a8-1fbd-4881-9251-7bf1599bf05f bridge vibr24
vlan24-enp2s0 70cb4491-0cfb-4f5c-a0b2-9cee71eb115a vlan enp2s0.24
Connection 1 1e65cdef-c819-3c30-8fc8-23f4d13f7fe1 802-3-ethernet enp2s0
使用 brctl 检查以确认 VLAN 已启动并且绑定到桥接:
$ brctl show
bridge name bridge id STP enabled interfaces
vibr24 8000.cafedefaced0 yes enp2s0.24
因此,根据您的配置进行调整,这个应该适合您:
nmcli con add con-name vlan24-team0 type vlan id 24 dev team0
nmcli con add con-name br24 type bridge ifname vibr24 stp yes
nmcli con mod vlan24-team0 connection.slave-type bridge connection.master vibr24
附言:刚刚注意到这个问题实际上是 2015 年的,由于其他用户的赏金而被搁置。我的答案仍然解决了这个问题,因为在我尝试此解决方案之前,我确实重现了这种情况,并且遇到了与 OP 相同的“未找到适合此连接的设备”问题。