首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Debian 11上VLAN和网桥的连接

Debian 11上VLAN和网桥的连接
EN

Unix & Linux用户
提问于 2022-03-23 21:35:33
回答 1查看 4.7K关注 0票数 1

我试图在Linux键合主动备份(2个物理接口eth2和eth3,其中一个被使用)上进行配置,但也配置两个VLAN,然后将其连接到内部桥接器。我看到了两种连接方式,两种都起作用,

  1. 第一种方法工作良好,看起来很容易,但是所有的VLAN都是通过单个物理接口(较低的带宽)路由的。
  2. 第二个是有问题的(对我来说),但我更喜欢这个秒,因为它允许通过eth2路由一个VLAN,通过eth3路由第二个VLAN (具有容错的更大的带宽)。
  • 我不想要bond-mode 4 = 802.3ad AKA (服务器连接到不同的思科交换机,我已经听说过和看到了这些配置的一些问题),所以bond-mode active-backup需要足够。
代码语言:javascript
复制
# 1. Two NICs agregated to one bonding, and then separate VLANS from bonding interface: 

eth2           bond1.10  - xenbr10
     > bond1 <
eth3           bond1.15 - xenbr15


# 2. VLANs separated form physical NIC, then aggregate to separate binding interfaces.

       eth2.15 ...
eth2 <
       eth2.10
                > bond10  - xenbr10
       eth3.10
eth3 <
       eth3.15 ...

我有带有Debian11的服务器,2个网络接口,安装了软件包vlanbridge-utilsifenslave (在2.13版本中测试回购,原因是2.12中的这个问题 )。在系统中加载了8021qbonding模块。

问题1:连接的第一个选择是最佳实践吗?为什么?我是在问,因为在互联网上找到的大部分(或者全部)教程都是关于第一次连接的(甚至是Debian Wiki)。

选项1

这很好,我可以通过控制台或配置文件来完成。缺点是:两个VLAN总是使用单个接口发送的。我当前的/etc/network/interfaces (删除了不重要的元素)

代码语言:javascript
复制
iface eth2 inet manual
iface eth3 inet manual

auto bond1
iface bond1 inet manual
    bond-slaves eth2 eth3
    bond-mode active-backup
    bond-miimon 100
    bond-downdelay 200
    bond-updelay 200

iface bond1.10 inet manual
    vlan-raw-device bond1
iface bond1.15 inet manual
    vlan-raw-device bond1

auto xenbr10
iface xenbr10 inet static
    address 1.2.3.4/24
    bridge_ports bond1.10

在重新启动系统之后,这个配置是正确的,但是我想配置并使用第二个选项。

选项2:从shell工作,无法从配置文件

执行

我可以通过命令行完成这个配置:

代码语言:javascript
复制
ifconfig eth2 up
ifconfig eth3 up
#setting up VLANs
ip link add link eth2 name eth2.10 type vlan id 10
ip link add link eth3 name eth3.10 type vlan id 10

#creating bonding interface with 2 slaves NIC
ip link add name bond1 type bond mode active-backup
ip link set dev eth2.10 down
ip link set dev eth3.10 down
ip link set master bond10 dev eth2.10
ip link set master bond10 dev eth3.10

ip link set up dev bond10
ip link set dev eth2.10 up
ip link set dev eth3.10 up

### Bridge + bonding
brctl addbr xenbr10
brctl addif xenbr10 bond10

ip addr add 1.2.3.4/24 dev xenbr10
ip link set dev xenbr10 up

网络已经开通:

代码语言:javascript
复制
cat /proc/net/bonding/bond10
Ethernet Channel Bonding Driver: v5.10.0-12-amd64

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth2.10
MII Status: up
(..)

Slave Interface: eth2.10
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: (..)

Slave Interface: eth3.10
MII Status: up
(..)

但是我不能创建配置文件来使这个永久化。我尝试过很多这样的选择,但没有运气。如果我将接口eth2.10直接连接到某些xenbr10,它就能工作。

代码语言:javascript
复制
iface eth2.10 inet manual
    vlan-raw-device eth2
iface eth3.10 inet manual
    vlan-raw-device eth3
    bond-master bond10 #It doesn't change nothing, for testing

auto bond10
iface bond10 inet manual
    bond-slaves eth2.10 eth3.10
    #bond-slaves none
    bond-mode active-backup
    bond-miimon 100
    bond-downdelay 200
    bond-updelay 200

auto xenbr10
iface xenbr10 inet static
    address 1.2.3.4/24
    bridge_ports bond1.10

在重新启动系统之后,通常会出现如下错误:

ifup六八六:未能将eth2.10奴役到bond10。bond10准备好了吗?连接接口了吗?

问题2:这个配置有什么问题?我试过了

  • 将eth2.10配置设置在bond10配置之上或下面,
  • bond-master bond10配置部分中对eth2.10和bond-slaves none使用bond10条目
  • bond-slaves eth2.10 eth3.10部件中使用bond10条目
  • 使用auto eth2.10
EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2022-03-25 12:29:55

经过一天的搜索和测试,我找到了两个解决方案。第一个配置可能不太优雅,但有效:

代码语言:javascript
复制
# Using default ifupdown on Debian 11:
# Set up NIC and NIC's alias with VLAN:
auto eth2
iface eth2 inet manual
    post-up ip link add link eth2 name eth2.10 type vlan id 10
    post-up ip link add link eth2 name eth2.15 type vlan id 15
auto eth3
iface eth3 inet manual
    post-up ip link add link eth3 name eth3.10 type vlan id 10
    post-up ip link add link eth3 name eth3.15 type vlan id 15

auto bond533
iface bond533 inet manual
    bond-slaves eth2.533 eth3.533
    bond-mode active-backup
# (...)

多亏了A.B.S的评论(链接),我发现了使用ifupdown2的更好的解决方案。贝华意识到:在安装这个包(它移除旧的ifupdown)期间,我已经失去了网络,直到重新启动(也许重新启动网络就足够了,而不是测试)。

代码语言:javascript
复制
# After installing ifupdown2:
# No need to set up physical NIC or VLAN interface!
#iface eth2.10 inet manual
#   vlan-raw-device eth2
#iface eth2.533 inet manual
#   vlan-raw-device eth2

#Set up bonding and brige (the same as with ifupdown)
auto bond533
iface bond533 inet manual
    bond-slaves eth2.533 eth3.533
    bond-mode active-backup
# (...)

对我来说,这种简单的配置是正确的,这有点奇怪。看起来,ifupdown2可以建立必要的连接-从网络接口(甚至vlans),而不需要更早地配置它们。

我是基于这个页面上的配置:https://docs.nvidia.com/networking-ethernet-software/knowledge-base/Configuration-and-Usage/Network-Interfaces/Compare-ifupdown2-with-ifupdown/

票数 1
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/696582

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档