示例:通过在中继接口上启用 MAC 固定功能来防止桥接域中的环路
此示例说明如何通过在中继接口上启用 MAC 固定功能来避免桥接域中的环路。
要求
此示例使用以下硬件和软件组件:
MX 系列 5G 通用路由平台
在路由器上运行的 Junos OS 16.1 版
概述
当 MAC 地址频繁出现在与其获知地址不同的物理接口上时,就会发生 MAC 移动。频繁的 MAC 移动表示存在环路。环路可能发生在第 2 层网桥和 VPLS 网络中。为避免环路,您可以在接口上启用 MAC 固定功能。仅当启用了通过接口动态学习 MAC 地址时,MAC 固定功能才适用。
此示例说明如何在桥接域中的三个聚合中继接口上启用 MAC 固定。
拓扑
在此示例中,您将接口配置为 MX 系列路由器上的聚合以太网接口,您可以将其他四个接口和配置为聚合以太网接口,ae1.
并且每个聚合以太网接口都配置为xe-0/3/1
中继接口ge-4/1/6, xe-4/2/0,
ge-4/0/6
xe-0/1/1
xe-4/3/0,
。ae3.
ae2
中继接口仅接受标记的数据包,并在指定的网桥域 . BD_Trunk_all
指定接口和网桥域的 VLAN ID 列表。在任何聚合中继接口上收到标记的数据包时,将接受该数据包,并在配置了匹配 ID 的网桥域内转发数据包。
在网桥域中,指定 VLAN ID 后,指定为每个聚合以太网中继接口上可获知的最大 MAC 地址数,并指定131000 1048575 为桥接域或 VLAN 的 MAC 地址表的大小。
在此拓扑中,可能会发生频繁的 MAC 移动,从而导致环路。要防止这些环路,您可以配置 MAC 固定。在接口上配置 MAC 固定时,无法在同一桥接域中的另一个接口上获知在该接口上获知的 MAC 地址。例如,在聚合以太网接口 ae1.
上配置 MAC 固定 当此接口上收到数据包时,将接受该数据包,并使用匹配的 ID 在桥接域内转发数据包。但是,如果在任何其他中继接口上收到具有相同 MAC 地址的数据包,则假设 ae2,
该数据包被丢弃或丢弃,因为该 MAC 地址被固定到中继接口 ae1
。此行为对于路由器上配置的所有中继接口都是通用的,无论中继接口上是否启用了访问固定。
配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改任何必要的详细信息以匹配您的网络配置,然后将命令复制并粘贴到 [edit] 层次结构级别的 CLI 中。
set interfaces xe-0/1/1 gigether-options 802.3ad ae1 set interfaces xe-0/3/1 gigether-options 802.3ad ae1 set interfaces ge-4/0/6 gigether-options 802.3ad ae3 set interfaces ge-4/1/6 gigether-options 802.3ad ae3 set interfaces xe-4/2/0 gigether-options 802.3ad ae2 set interfaces xe-4/3/0 gigether-options 802.3ad ae2 set interfaces ae1 flexible-vlan-tagging set interfaces ae1 encapsulation flexible-ethernet-services set interfaces ae1 unit 0 family bridge interface-mode trunk set interfaces ae1 unit 0 family bridge vlan-id-list 1-5 set interfaces ae2 flexible-vlan-tagging set interfaces ae2 encapsulation flexible-ethernet-services set interfaces ae2 unit 0 family bridge interface-mode trunk set interfaces ae2 unit 0 family bridge vlan-id-list 1-5 set interfaces ae3 flexible-vlan-tagging set interfaces ae3 encapsulation flexible-ethernet-services set interfaces ae3 unit 0 family bridge interface-mode trunk set interfaces ae3 unit 0 family bridge vlan-id-list 1-5 set bridge-domains BD_Trunk_all vlan-id-list 1-5 set bridge-domains BD_Trunk_all bridge-options mac-table-size 1048575 set bridge-domains BD_Trunk_all bridge-options interface ae1.0 interface-mac-limit 131000 set bridge-domains BD_Trunk_all bridge-options interface ae2.0 interface-mac-limit 131000 set bridge-domains BD_Trunk_all bridge-options interface ae3.0 interface-mac-limit 131000 set switch-options interface ae1.0 interface-mac-limit 131000 set switch-options interface ae1.0 mac-pinning set switch-options interface ae2.0 interface-mac-limit 131000 set switch-options interface ae2.0 mac-pinning set switch-options interface ae3.0 interface-mac-limit 131000 set switch-options interface ae3.0 mac-pinning
程序
分步过程
以下示例要求您在配置层次结构中导航各个级别。有关导航 CLI 的信息,请参阅 在配置模式下使用 CLI 编辑器
要在网桥域中的中继接口上配置 MAC 固定:
将接口配置为成员聚合以太网接口。
[edit interfaces] user@host#
set interfaces xe-0/1/1 gigether-options 802.3ad ae1
user@host#set interfaces xe-0/3/1 gigether-options 802.3ad ae1
user@host#set interfaces ge-4/0/6 gigether-options 802.3ad ae3
user@host#set interfaces ge-4/1/6 gigether-options 802.3ad ae3
user@host#set interfaces xe-4/2/0 gigether-options 802.3ad ae2
user@host#set interfaces xe-4/3/0 gigether-options 802.3ad ae2
将聚合以太网接口配置为中继接口,并指定 VLAN ID 列表。
user@host#
set interfaces ae1 flexible-vlan-tagging
user@host#set interfaces ae1 encapsulation flexible-ethernet-services
user@host#set interfaces ae1 unit 0 family bridge interface-mode trunk
user@host#set interfaces ae1 unit 0 family bridge vlan-id-list 1-5
user@host#set interfaces ae2 flexible-vlan-tagging
user@host#set interfaces ae2 encapsulation flexible-ethernet-services
user@host#set interfaces ae2 unit 0 family bridge interface-mode trunk
user@host#set interfaces ae2 unit 0 family bridge vlan-id-list 1-5
user@host#set interfaces ae3 flexible-vlan-tagging
user@host#set interfaces ae3 encapsulation flexible-ethernet-services
user@host#set interfaces ae3 unit 0 family bridge interface-mode trunk
user@host#set interfaces ae3 unit 0 family bridge vlan-id-list 1-5
指定网桥域的名称。
[edit bridge-domains] user@host#
set bridge-domains BD_Trunk_all vlan-id-list 1-5
指定桥接域的 MAC 地址表的大小。
user@host#
set bridge-domains BD_Trunk_all bridge-options mac-table-size 1048575
指定可在所有三个中继接口上获知的最大 MAC 地址数。
user@host#
set bridge-domains BD_Trunk_all bridge-options interface ae1.0 interface-mac-limit 131000
user@host#set bridge-domains BD_Trunk_all bridge-options interface ae2.0 interface-mac-limit 131000
user@host#set bridge-domains BD_Trunk_all bridge-options interface ae3.0 interface-mac-limit 131000
在 [
edit switch-options
] 层次结构级别的每个聚合以太网接口上配置 MAC 固定。[edit switch-options] user@host#
set switch-options interface ae1.0 interface-mac-limit 131000
user@host#set switch-options interface ae1.0 mac-pinning
user@host#set switch-options interface ae2.0 interface-mac-limit 131000
user@host#set switch-options interface ae2.0 mac-pinning
user@host#set switch-options interface ae3.0 interface-mac-limit 131000
user@host#set switch-options interface ae3.0 mac-pinning
结果
在配置模式下,输入 show interfaces
和 show bridge-domains
命令确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明以更正配置。
user@host#show interfaces
interfaces { xe-0/0/0 { flexible-vlan-tagging; encapsulation flexible-ethernet-services; unit 0 { family bridge { interface-mode trunk; vlan-id-list 1-5; } } } xe-0/1/1 { gigether-options { 802.3ad ae1; } } xe-0/3/1 { gigether-options { 802.3ad ae1; } } ge-4/0/6 { gigether-options { 802.3ad ae3; } } ge-4/1/6 { gigether-options { 802.3ad ae3; } } xe-4/2/0 { gigether-options { 802.3ad ae2; } } xe-4/3/0 { gigether-options { 802.3ad ae2; } } ae1 { flexible-vlan-tagging; encapsulation flexible-ethernet-services; unit 0 { family bridge { interface-mode trunk; vlan-id-list 1-5; } } } ae2 { flexible-vlan-tagging; encapsulation flexible-ethernet-services; unit 0 { family bridge { interface-mode trunk; vlan-id-list 1-5; } } } ae3 { flexible-vlan-tagging; encapsulation flexible-ethernet-services; unit 0 { family bridge { interface-mode trunk; vlan-id-list 1-5; } } } } user@host#show bridge-domains
bridge-domains { BD_Trunk_all { vlan-id-list 1-5; bridge-options { mac-table-size { 1048575; } interface ae1.0 { interface-mac-limit { 131000; } } interface ae2.0 { interface-mac-limit { 131000; } } interface ae3.0 { interface-mac-limit { 131000; } } } } } user@host#show switch-options
switch-options { interface ae1.0 { interface-mac-limit { 131000; } mac-pinning; } interface ae2.0 { interface-mac-limit { 131000; } mac-pinning; } interface ae3.0 { interface-mac-limit { 131000; } mac-pinning; } }
如果已完成设备配置,请从配置模式输入 commit
。
验证
验证是否正确配置了 MAC 固定
目的
确保在中继接口上启用了 MAC 固定。
行动
在操作模式下,输入 show l2-learning interface
命令。
user@host> show l2-learning interface
Routing Instance Name : default-switch
Logical Interface flags (DL -disable learning, AD -packet action drop,
LH - MAC limit hit, DN - Interface Down, MP - MAC Pinning)
Logical BD MAC STP Logical
Interface Name Limit State Interface flags
xe-0/0/0.0 8192
BD_Tru.. 1024 Forwarding
BD_Tru.. 1024 Forwarding
BD_Tru.. 1024 Forwarding
BD_Tru.. 1024 Forwarding
BD_Tru.. 1024 Forwarding
Routing Instance Name : default-switch
Logical Interface flags (DL -disable learning, AD -packet action drop,
LH - MAC limit hit, DN - Interface Down, MP - MAC Pinning)
Logical BD MAC STP Logical
Interface Name Limit State Interface flags
ae1.0 131000 MP
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
Routing Instance Name : default-switch
Logical Interface flags (DL -disable learning, AD -packet action drop,
LH - MAC limit hit, DN - Interface Down, MP - MAC Pinning)
Logical BD MAC STP Logical
Interface Name Limit State Interface flags
ae2.0 131000 MP
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
Routing Instance Name : default-switch
Logical Interface flags (DL -disable learning, AD -packet action drop,
LH - MAC limit hit, DN - Interface Down, MP - MAC Pinning)
Logical BD MAC STP Logical
Interface Name Limit State Interface flags
ae3.0 131000 MP
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
BD_Tru.. 131000 Forwarding
意义
该 Interface flags
字段指示启用了 MAC 固定的接口。