Linux 绑定 VLAN 问题

Sat*_*ish 3 linux bonding vlan

您认为以下配置有意义吗?是否BONDTING_OPT支持 VLAN 接口?我想确保我的接口在上游设备关闭时进行故障转移。

ifcfg-bond0

$ cat /etc/sysconfig/network-scripts/ifcfg-bond0
NAME=bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
BONDING_OPTS="mode=1 miimon=500 downdelay=1000 primary=eno1 primary_reselect=always"
Run Code Online (Sandbox Code Playgroud)

ifcfg-bond0.10

$ cat /etc/sysconfig/network-scripts/ifcfg-bond0.10
NAME=bond0.10
DEVICE=bond0.10
ONPARENT=yes
BOOTPROTO=dhcp
VLAN=yes
BONDING_OPTS="mode=1 arp_interval=1000 arp_ip_target=10.10.0.1 miimon=500 downdelay=1000 primary=eno1 primary_reselect=always"
NM_CONTROLLED=no
Run Code Online (Sandbox Code Playgroud)

ifcfg-bond0.20

$ cat /etc/sysconfig/network-scripts/ifcfg-bond0.20
NAME=bond0.20
DEVICE=bond0.20
ONPARENT=yes
BOOTPROTO=dhcp
VLAN=yes
BONDING_OPTS="mode=1 arp_interval=1000 arp_ip_target=74.xx.xx.1 miimon=500 downdelay=1000 primary=eno1 primary_reselect=always"
NM_CONTROLLED=no
Run Code Online (Sandbox Code Playgroud)

the*_*btm 7

您需要配置设备,然后是绑定,最后是 VLAN 配置文件。您还必须注意哪些属性在何处起作用,例如bonding_opts,它只能在bond 本身中,而不是VLAN 配置文件,因为VLAN 文件将无法直接访问以太网连接。

我还发现了这个 RHEL 6 文档,它对其进行了更多解释。它对于 RHEL 7 / CentOS 7 来说仍然是最可靠的。

添加:

绑定负责管理绑定使用的物理连接。如下面的驱动程序输出所示,VLAN 无法看到物理连接;他们只看到负责他们的设备,在这种情况下,bond0。

还在这里解释了另一个观点: bonded-and-primary-virtual-ip-addresses-and-vlan-tagged 答案

笔记:

  • 我知道这很有效,因为我在 RHEL 7 系统上使用它。
  • 如果您需要更多 VLAN,只需cp ifcfg-bond0.20 ifcfg-bond0.30更新必填字段。

图表:

eth0         vlan1
    \       / 
      bond0 -vlan2
    /       \
eth1         vlan3
Run Code Online (Sandbox Code Playgroud)

例子:

[工作配置]

 ==> ifcfg-eth0 <==
 DEVICE=eth0
 NAME=bond0-slave
 HWADDR=xx:xx:xx:xx:xx:xx
 ONBOOT=yes
 BOOTPROTO=none
 MASTER=bond0
 SLAVE=yes
 USERCTL=no
 NM_CONTRLLED=no

 ==> ifcfg-eth1 <==
 DEVICE=eth1
 NAME=bond0-slave
 HWADDR=xx:xx:xx:xx:xx:xx
 ONBOOT=yes
 BOOTPROTO=none
 MASTER=bond0
 SLAVE=yes
 USERCTL=no
 NM_CONTRLLED=no

 ==> ifcfg-bond0 <==
 DEVICE=bond0
 TYPE=bond
 BONDING_MASTER=yes
 NAME=bond0
 ONBOOT=yes
 BONDING_OPTS="miimon=100 mode=active-backup"

 ==> ifcfg-bond0.10 <==
 VLAN=yes
 TYPE=vlan
 DEVICE=bond0.10
 PHYSDEV=bond0
 VLAN_ID=10
 BOOTPROTO=none
 NAME=bond0.10
 ONBOOT=yes
 IPADDR=x.x.x.x
 PREFIX=24
 GATEWAY=x.x.x.1
 IPV6INIT=no
 DEFROUTE=yes

 ==> ifcfg-bond0.20 <==
 VLAN=yes
 TYPE=vlan
 DEVICE=bond0.20
 PHYSDEV=bond0
 VLAN_ID=20
 BOOTPROTO=none
 NAME=bond0.20
 ONBOOT=yes
 IPADDR=x.x.x.x
 PREFIX=24
 GATEWAY=x.x.x.1
 IPV6INIT=no
 DEFROUTE=no
Run Code Online (Sandbox Code Playgroud)

使用中的驱动程序:

[thebtm@server network-scripts]$ sudo cat /proc/net/bonding/bond0 
 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

 Bonding Mode: fault-tolerance (active-backup)
 Primary Slave: None
 Currently Active Slave: eth0
 MII Status: up
 MII Polling Interval (ms): 100
 Up Delay (ms): 0
 Down Delay (ms): 0

 Slave Interface: eth0
 MII Status: up
 Speed: 10000 Mbps
 Duplex: full
 Link Failure Count: 0
 Permanent HW addr: xx:xx:xx:xx:xx:xx
 Slave queue ID: 0

 Slave Interface: eth1
 MII Status: up
 Speed: 10000 Mbps
 Duplex: full
 Link Failure Count: 0
 Permanent HW addr: xx:xx:xx:xx:xx:xx
 Slave queue ID: 0

[thebtm@server network-scripts]$ sudo cat /proc/net/vlan/bond0.10
bond0.10    VID: 10      REORDER_HDR: 1  dev->priv_flags: 1
         total frames received  29091167441
          total bytes received 139953896100912
      Broadcast/Multicast Rcvd           18

      total frames transmitted  21506143557
       total bytes transmitted 14822425401382
Device: bond0
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
 EGRESS priority mappings: 
[thebtm@server network-scripts]$ sudo cat /proc/net/vlan/bond0.20
bond0.20    VID: 20      REORDER_HDR: 1  dev->priv_flags: 1
         total frames received      2637498
          total bytes received    290061293
      Broadcast/Multicast Rcvd            5

      total frames transmitted            6
       total bytes transmitted          252
Device: bond0
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
 EGRESS priority mappings: 
Run Code Online (Sandbox Code Playgroud)