CRS1xx/2xx series switch examples

本页提供 CRS1xx/2xx 系列交换机上 Cloud Router Switch 功能的配置示例和用例,涵盖端口交换、带 VLAN 过滤的管理访问设置以及基于 IP 访问的安全注意事项。

CRS1xx/2xx 系列交换机示例

Cloud Router Switch 系列是高度集成的交换机,配备高性能 MIPS CPU 和功能丰富的数据包处理器。CRS 交换机可设计用于各种以太网应用,包括非管理型交换机、二层管理型交换机、运营商交换机以及无线/有线统一数据包处理。

危险

本文适用于 CRS1xx 和 CRS2xx 系列交换机,不适用于搭载 Marvell Prestera 交换机的 MikroTik 设备(例如 CRS3xx)。对于搭载 Marvell Prestera 交换机的 MikroTik 设备,请参阅 Marvell Prestera 交换机芯片功能手册。 | Features | Description | | :-- | :-- | | 转发 | 可配置端口用于交换或路由完整的无阻塞线速交换单播 FDB 中最多 16k MAC 条目用于二层单播转发多播 FDB 中最多 1k MAC 条目用于多播转发保留 FDB 中最多 256 MAC 条目用于控制和管理目的所有转发数据库支持 IVL 和 SVL可配置基于端口的 MAC 学习限制巨型帧支持(CRS1xx/2xx:9204 字节;CRS125/CRS109:4064 字节)IGMP Snooping 支持 | | 镜像 | 各种类型的镜像:基于端口的镜像基于 VLAN 的镜像基于 MAC 的镜像2 个独立的镜像分析器端口 | | VLAN | 完全兼容 IEEE802.1Q 和 IEEE802.1ad VLAN4k 活动 VLAN灵活的 VLAN 分配:基于端口的 VLAN基于协议的 VLAN基于 MAC 的 VLAN从任意到任意的 VLAN 转换和交换1:1 VLAN 交换 - VLAN 到端口映射VLAN 过滤 | | 端口隔离与泄漏 | 适用于 Private VLAN 实现3 种端口配置文件类型:Promiscuous、Isolated 和 Community最多 28 个 Community 配置文件泄漏配置文件允许绕过出站 VLAN 过滤 | | Trunking | 支持静态链路聚合组最多 8 个 Port Trunk 组每个 Port Trunk 组最多 8 个成员端口硬件自动故障转移和负载均衡 | | 服务质量(QoS) | 灵活的 QoS 分类和分配:基于端口基于 MAC基于 VLAN基于协议基于 PCP/DEI基于 DSCP基于 ACL用于服务提供商和客户网络之间 QoS 域转换的 QoS 重标记和重映射根据配置的优先级覆盖每个 QoS 分配 | | 整形与调度 | 每个物理端口 8 个队列按端口、按队列、按队列组整形 | | 访问控制列表 | 入口和出口 ACL 表最多 128 条 ACL 规则(受 RouterOS 限制)基于端口、L2、L3、L4 协议头字段的分类ACL 操作包括过滤、转发以及修改协议头字段 |

适用的交换机型号


此表说明了 Cloud Router Switch 型号之间的主要区别。

型号交换芯片CPU无线SFP+ 端口访问控制列表巨型帧(字节)
CRS105-5S-FBQCA-8511400MHz--+9204
CRS106-1C-5SQCA-8511400MHz--+9204
CRS112-8G-4SQCA-8511400MHz--+9204
CRS210-8G-2S+QCA-8519400MHz-++9204
CRS212-1G-10S-1S+QCA-8519400MHz-++9204
CRS226-24G-2S+QCA-8519400MHz-++9204
CRS125-24G-1SQCA-8513L600MHz---4064
CRS125-24G-1S-2HnDQCA-8513L600MHz+--4064
CRS109-8G-1S-2HnDQCA-8513L600MHz+--4064

缩写与说明


CVID - 客户 VLAN id:IEEE 802.1ad 帧的内层 VLAN 标签 id

SVID - 服务 VLAN id:IEEE 802.1ad 帧的外层 VLAN 标签 id

IVL - 独立 VLAN 学习 - 学习和查找基于 MAC 地址和 VLAN ID 两者。

SVL - 共享 VLAN 学习 - 学习和查找基于 MAC 地址 - 而不基于 VLAN ID。

TPID - 标签协议标识符

PCP - 优先级代码点:一个 3 位字段,指代 IEEE 802.1p 优先级

DEI - 丢弃资格指示符

DSCP - 差分服务代码点

丢弃优先级 - 一种内部 CRS 交换机 QoS 属性,用于数据包入队或丢弃。

端口交换


要在 CRS1xx/2xx 系列交换机上设置端口交换,请查看网桥硬件卸载页面。

警告

当创建硬件卸载网桥并添加交换端口组时,CRS 交换机中会创建动态保留 VLAN 条目(VLAN4091;VLAN4090;VLAN4089;等)。这些 VLAN 是内部操作所必需的,其优先级低于用户配置的 VLAN。 危险

可以通过使用多个启用硬件卸载的网桥来创建多个隔离的交换机组;这仅在 CRS1xx/2xx 系列交换机上可行。对于更复杂的设置(例如 VLAN 过滤),你应该改用端口隔离功能。

多个交换机组

CRS1xx/2xx 系列交换机允许你使用多个带硬件卸载的网桥;这使你可以轻松隔离多个交换机组。只需创建多个网桥并启用硬件卸载即可完成。

警告

多个硬件卸载网桥配置被设计为一种快速简单的端口隔离解决方案,但它限制了 CRS 交换机芯片支持的部分 VLAN 功能。对于高级配置,请在 CRS 交换机芯片内为所有端口使用一个网桥,配置 VLAN,并使用端口隔离配置文件配置隔离端口组。 危险

CRS1xx/2xx 系列交换机可以在启用 (R)STP 的情况下运行多个硬件卸载网桥,但不建议这样做,因为该设备并非设计为在硬件级别运行多个 (R)STP 实例。要隔离多个交换机组并启用 (R)STP,你应该使用端口隔离配置文件配置来隔离端口组。

管理访问配置


通常,交换机只应使用内置交换机芯片转发数据包,出于安全原因不应允许访问设备本身。可以使用设备的串口进行管理访问,但在大多数情况下,这种访问方式并不理想,使用 IP 地址的访问更合适。在这种情况下,你需要配置管理访问。

在所有类型的管理访问中,都假定端口必须一起交换。使用以下命令将所需端口一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether3 hw=yes
add bridge=bridge1 interface=ether4 hw=yes
add bridge=bridge1 interface=ether5 hw=yes

你还应该为网桥接口分配一个 IP 地址,以便可以通过 IP 地址访问设备(也可以通过 MAC 地址访问设备):

/ip/address
add address=192.168.88.1/24 interface=bridge1

未标记

如果未启用无效 VLAN 过滤,则已经允许从任何端口使用带标签或未标记(VLAN 0)流量对设备进行管理访问,但这不是良好做法;这可能导致安全问题,并在某些情况下(最常见的是广播类型流量)导致设备 CPU 过载。

如果你打算使用无效 VLAN 过滤(你应该这样做),那么你将从其访问交换机的端口必须添加到 VLAN 表中以供未标记(VLAN 0)流量使用,例如,如果你要从 ether2 访问交换机:

/interface/ethernet/switch/vlan
add vlan-id=0 ports=ether2,switch1-cpu  

已标记

仅允许带标签流量通过特定端口对设备进行管理访问是更好的做法。例如,要仅允许 VLAN99 通过 ether2 访问设备,你应首先在 VLAN 表中添加一个条目,这将允许所选端口和 CPU 端口(switch1-cpu)转发所选 VLAN ID,从而允许管理访问:

/interface/ethernet/switch/vlan
add ports=ether2,switch1-cpu vlan-id=99

从 CPU 发出的数据包(例如 ping 回复)将不具有 VLAN 标签,要解决此问题,你需要指定哪些端口应始终为特定 VLAN ID 发送带有 VLAN 标签的数据包:

/interface/ethernet/switch/egress-vlan-tag
add tagged-ports=ether2,switch1-cpu vlan-id=99

在设置有效的 VLAN99 配置后,你可以启用未知/无效 VLAN 过滤,这将不允许通过与 VLAN 表中指定的端口不同的端口进行管理访问:

/interface/ethernet/switch
set drop-if-invalid-or-src-port-not-member-of-vlan-on-ports=ether2,ether3,ether4,ether5

在此示例中,将使用 VLAN99 访问设备。必须在网桥上创建 VLAN 接口并为其分配 IP 地址。

/interface/vlan
add interface=bridge1 name=MGMT vlan-id=99
/ip/address
add address=192.168.99.1/24 interface=MGMT

VLAN


危险

锁定风险。 强烈建议在配置 VLAN 之前准备好并测试串口控制台线缆。配置错误很容易使你无法访问 CPU 或所连接的端口。 提示

排查缓存的 MAC 地址问题。 由于已学习的 MAC 地址,某些更改可能看起来有延迟。如果更改后流量未按预期流动,请刷新单播转发数据库: /interface/ethernet/switch/unicast-fdb/flush 信息

架构最佳实践。 使用多个硬件卸载网桥是实现简单端口隔离的快速方法,但它限制了 CRS 交换机芯片上的高级 VLAN 功能。对于高级设置,请为所有端口使用单个网桥,配置你的 VLAN,并使用端口隔离配置文件隔离端口组。

基于端口的 VLAN

警告

对于 CRS3xx 系列设备,你必须使用网桥 VLAN 过滤;你可以在网桥 VLAN 过滤章节中阅读更多相关内容。

示例 1(中继和接入端口)

Access Ports

将所需端口一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

为每个接入端口指定交换机必须在未标记(VLAN0)流量上设置的 VLAN ID:

/interface/ethernet/switch/ingress-vlan-translation
add ports=ether6 customer-vid=0 new-customer-vid=200
add ports=ether7 customer-vid=0 new-customer-vid=300
add ports=ether8 customer-vid=0 new-customer-vid=400

警告

在 /interface/ethernet/switch/ingress-vlan-translation 下创建条目时,交换机芯片将在指定端口的入站帧上添加 VLAN 标签。要为出站帧移除同一端口上的 VLAN 标签,应为同一 VLAN ID 创建一个 /interface/ethernet/switch/egress-vlan-tag 条目,其中仅指定带标签端口。如果特定 VLAN 仅在接入端口之间转发,则仍应创建不带任何带标签端口的 /interface/ethernet/switch/egress-vlan-tag 条目。另一种选择是在 /interface/ethernet/switch/egress-vlan-translation 菜单下创建额外条目以设置未标记(VLAN0)流量。 你还必须指定哪些 VLAN 应带 VLAN 标签发送到中继端口。使用 tagged-ports 属性设置中继端口:

/interface/ethernet/switch/egress-vlan-tag
add tagged-ports=ether2 vlan-id=200
add tagged-ports=ether2 vlan-id=300
add tagged-ports=ether2 vlan-id=400

将条目添加到 VLAN 表以指定每个端口和每个 VLAN ID 的 VLAN 成员关系:

/interface/ethernet/switch/vlan
add ports=ether2,ether6 vlan-id=200
add ports=ether2,ether7 vlan-id=300
add ports=ether2,ether8 vlan-id=400

在设置有效的 VLAN 配置后,你可以启用未知/无效 VLAN 过滤:

/interface/ethernet/switch
set drop-if-invalid-or-src-port-not-member-of-vlan-on-ports=ether2,ether6,ether7,ether8

警告

可以同时使用内置交换机芯片和 CPU 来创建 Switch-Router 设置,其中设备同时充当交换机和路由器。

示例 2(中继和混合端口)

Hybrid Ports

将所需端口一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

为每个接入端口指定交换机必须在未标记(VLAN0)流量上设置的 VLAN ID:

/interface/ethernet/switch/ingress-vlan-translation
add ports=ether6 customer-vid=0 new-customer-vid=200
add ports=ether7 customer-vid=0 new-customer-vid=300
add ports=ether8 customer-vid=0 new-customer-vid=400

通过将端口指定为 tagged-ports,交换机将始终以带有相应 VLAN ID 的带标签数据包形式发送数据包。根据上图添加适当的条目:

/interface/ethernet/switch/egress-vlan-tag
add tagged-ports=ether2,ether7,ether8 vlan-id=200
add tagged-ports=ether2,ether6,ether8 vlan-id=300
add tagged-ports=ether2,ether6,ether7 vlan-id=400

将条目添加到 VLAN 表以指定每个端口和每个 VLAN ID 的 VLAN 成员关系:

/interface/ethernet/switch/vlan
add ports=ether2,ether6,ether7,ether8 vlan-id=200 learn=yes
add ports=ether2,ether6,ether7,ether8 vlan-id=300 learn=yes
add ports=ether2,ether6,ether7,ether8 vlan-id=400 learn=yes

在设置有效的 VLAN 配置后,你可以启用未知/无效 VLAN 过滤:

/interface/ethernet/switch
set drop-if-invalid-or-src-port-not-member-of-vlan-on-ports=ether2,ether6,ether7,ether8

基于协议的 VLAN

Protocol Based VLAN

将所需端口一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

为 IP 和 ARP 协议设置 VLAN:

/interface/ethernet/switch/protocol-based-vlan
add port=ether2 protocol=arp set-customer-vid-for=all new-customer-vid=0
add port=ether6 protocol=arp set-customer-vid-for=all new-customer-vid=200
add port=ether2 protocol=ip set-customer-vid-for=all new-customer-vid=0
add port=ether6 protocol=ip set-customer-vid-for=all new-customer-vid=200

为 IPX 协议设置 VLAN:

/interface/ethernet/switch/protocol-based-vlan
add port=ether2 protocol=ipx set-customer-vid-for=all new-customer-vid=0
add port=ether7 protocol=ipx set-customer-vid-for=all new-customer-vid=300

为 AppleTalk AARP 和 AppleTalk DDP 协议设置 VLAN:

/interface/ethernet/switch/protocol-based-vlan
add port=ether2 protocol=0x80F3 set-customer-vid-for=all new-customer-vid=0
add port=ether8 protocol=0x80F3 set-customer-vid-for=all new-customer-vid=400
add port=ether2 protocol=0x809B set-customer-vid-for=all new-customer-vid=0
add port=ether8 protocol=0x809B set-customer-vid-for=all new-customer-vid=400

基于 MAC 的 VLAN

危险

在内部,基于 MAC 的 VLAN 中的所有 MAC 地址都会被哈希。某些 MAC 地址可能具有相同的哈希,如果该哈希与已加载的 MAC 地址的哈希匹配,则会阻止 MAC 地址加载到交换机芯片中,因此,建议将基于端口的 VLAN 与基于 MAC 的 VLAN 结合使用。这是硬件限制。 MAC Based VLAN

将所需端口一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether7 hw=yes

在接入端口上启用基于 MAC 的 VLAN 转换:

/interface/ethernet/switch/port
set ether7 allow-fdb-based-vlan-translate=yes

在基于 MAC 的 VLAN 表中添加 MAC 到 VLAN 的映射条目:

/interface/ethernet/switch/mac-based-vlan
add src-mac=A4:12:6D:77:94:43 new-customer-vid=200
add src-mac=84:37:62:DF:04:20 new-customer-vid=300
add src-mac=E7:16:34:A1:CD:18 new-customer-vid=400

在 ether2 端口上添加 VLAN200、VLAN300 和 VLAN400 标记以将其创建为 VLAN 中继端口:

/interface/ethernet/switch/egress-vlan-tag
add tagged-ports=ether2 vlan-id=200
add tagged-ports=ether2 vlan-id=300
add tagged-ports=ether2 vlan-id=400

此外,将条目添加到 VLAN 表,指定每个端口的 VLAN 成员关系,并启用未知/无效 VLAN 过滤,请参阅以下示例 - 未知/无效 VLAN 过滤。这对于将更多接口添加到网桥的网络设置是必需的,因为它允许定义 VLAN 边界。

VLAN 间路由

VLAN Routing

VLAN 间路由配置由两个主要部分组成 – 交换机芯片中的 VLAN 标记和 RouterOS 中的路由。此配置可以通过与 DHCP 服务器、Hotspot、PPP 以及每个 VLAN 的其他功能结合使用于许多应用中。

将所需端口一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

为所有 VLAN 在 CPU 端口上设置 VLAN 标记,使数据包在被路由之前带有标签:

/interface/ethernet/switch/egress-vlan-tag
add tagged-ports=switch1-cpu vlan-id=200
add tagged-ports=switch1-cpu vlan-id=300
add tagged-ports=switch1-cpu vlan-id=400

添加入口 VLAN 转换规则以确保在接入端口上完成正确的 VLAN ID 分配:

/interface/ethernet/switch/ingress-vlan-translation
add ports=ether6 customer-vid=0 new-customer-vid=200
add ports=ether7 customer-vid=0 new-customer-vid=300
add ports=ether8 customer-vid=0 new-customer-vid=400

在网桥接口之上创建 VLAN 接口:

/interface/vlan
add name=VLAN200 interface=bridge1 vlan-id=200
add name=VLAN300 interface=bridge1 vlan-id=300
add name=VLAN400 interface=bridge1 vlan-id=400

危险

确保 VLAN 接口创建在网桥接口之上,而不是任何物理接口之上。如果 VLAN 接口创建在从属接口上,则数据包可能无法正确接收,因此路由可能失败。更详细的信息可以在 从属接口上的 VLAN 接口手册页中找到。 在创建的 VLAN 接口上添加 IP 地址。在此示例中,三个 192.168.x.1 地址被添加到 VLAN200、VLAN300 和 VLAN400 接口:

/ip/address
add address=192.168.20.1/24 interface=VLAN200
add address=192.168.30.1/24 interface=VLAN300
add address=192.168.40.1/24 interface=VLAN400

未知/无效 VLAN 过滤

VLAN 成员关系在 VLAN 表中定义。添加带有 VLAN ID 和端口的条目会使该 VLAN 流量在这些端口上有效。在设置有效的 VLAN 配置后,可以启用未知/无效 VLAN 过滤。此 VLAN 过滤配置示例适用于 VLAN 间路由设置。

/interface/ethernet/switch/vlan
add ports=switch1-cpu,ether6 vlan-id=200
add ports=switch1-cpu,ether7 vlan-id=300
add ports=switch1-cpu,ether8 vlan-id=400
  • 选项 1:在特定端口上禁用无效 VLAN 转发(更常见)。
/interface/ethernet/switch
set drop-if-invalid-or-src-port-not-member-of-vlan-on-ports=ether6,ether7,ether8
  • 选项 2:在所有端口上禁用无效 VLAN 转发。
/interface/ethernet/switch
set forward-unknown-vlan=no

危险

在启用未知/无效 VLAN 过滤的单个交换机芯片上使用多个网桥可能导致意外行为。在使用 VLAN 过滤时应始终使用单网桥配置。如果需要端口隔离,则应使用端口隔离功能,而不是使用多个网桥。

VLAN 隧道(Q-in-Q)

此示例涵盖了典型的 VLAN 隧道用例,其中服务提供商设备添加另一个 VLAN 标签以进行独立转发,同时允许客户使用自己的 VLAN。

警告

此示例仅包含服务 VLAN 标记部分。建议在端口上额外设置未知/无效 VLAN 过滤配置。 QinQ

CRS-1:位于服务提供商网络边缘的第一台交换机必须通过入口 VLAN 转换规则正确识别来自端口上客户 VLAN ID 的流量,并分配新的服务 VLAN ID。服务提供商 VLAN 标签的 VLAN 中继端口配置位于同一个 egress-vlan-tag 表中。与基本基于端口 VLAN 配置的主要区别在于,CRS 交换机芯片必须设置为根据服务(外部)VLAN ID 而不是客户(内部)VLAN ID 进行转发。

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether1 hw=yes
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether9 hw=yes

/interface/ethernet/switch/ingress-vlan-translation
add customer-vid=200 new-service-vid=400 ports=ether1
add customer-vid=300 new-service-vid=500 ports=ether2

/interface/ethernet/switch/egress-vlan-tag
add tagged-ports=ether9 vlan-id=400
add tagged-ports=ether9 vlan-id=500

/interface/ethernet/switch
set bridge-type=service-vid-used-as-lookup-vid

CRS-2:服务提供商网络中的第二台交换机只需要交换端口即可根据服务(外部)VLAN ID 而不是客户(内部)VLAN ID 进行转发。

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether9 hw=yes
add bridge=bridge1 interface=ether10 hw=yes

/interface/ethernet/switch
set bridge-type=service-vid-used-as-lookup-vid

CRS-3:第三台交换机的配置与 CRS-1 相似:

  • 使用网桥的交换机组中的端口。
  • 入口 VLAN 转换规则以在端口上定义新的服务 VLAN 分配。
  • 服务提供商 VLAN 中继的 tagged-ports。
  • CRS 交换机芯片设置为在交换查找中使用服务 VLAN ID。
/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether3 hw=yes
add bridge=bridge1 interface=ether4 hw=yes
add bridge=bridge1 interface=ether10 hw=yes

/interface/ethernet/switch/ingress-vlan-translation
add customer-vid=200 new-service-vid=400 ports=ether3
add customer-vid=300 new-service-vid=500 ports=ether4

/interface/ethernet/switch/egress-vlan-tag
add tagged-ports=ether10 vlan-id=400
add tagged-ports=ether10 vlan-id=500

/interface/ethernet/switch
set bridge-type=service-vid-used-as-lookup-vid

CVID 堆叠

可以将 CRS1xx/CRS2xx 系列交换机用于 CVID 堆叠设置。CRS1xx/CRS2xx 系列交换机能够基于具有两个 CVID 标签(双 CVID 标签)的带标签数据包的外部标签进行 VLAN 过滤。这些交换机还能够在现有 CVID 标签之上添加另一个 CVID 标签(CVID 堆叠)。例如,在 ether1 接收带有 CVID 10 的带标签数据包,但要求 ether2 用另一个标签 CVID 20 发送这些数据包(VLAN20 内的 VLAN10)同时过滤掉任何其他 VLAN 的设置中,必须配置以下内容:

将 ether1 和 ether2 一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether1 hw=yes
add bridge=bridge1 interface=ether2 hw=yes

将交换机设置为基于服务标签(0x88a8)过滤 VLAN:

/interface/ethernet/switch
set bridge-type=service-vid-used-as-lookup-vid

在 ether1 上为具有 CVID 10 标签的数据包添加服务标签 SVID 20:

/interface/ethernet/switch/ingress-vlan-translation
add customer-vid=10 new-service-vid=20 ports=ether1

将 ether2 指定为 SVID 20 的带标签/中继端口:

/interface/ethernet/switch/egress-vlan-tag
add tagged-ports=ether2 vlan-id=20

允许 ether1 和 ether2 转发 SVID 20:

/interface/ethernet/switch/vlan
add ports=ether1,ether2 vlan-id=20

在 ether2 上将 SVID EtherType(0x88a8)覆盖为 CVID EtherType(0x8100):

/interface/ethernet/switch/port
set ether2 egress-service-tpid-override=0x8100 ingress-service-tpid-override=0x8100

启用未知/无效 VLAN 过滤:

/interface/ethernet/switch
set drop-if-invalid-or-src-port-not-member-of-vlan-on-ports=ether1,ether2

警告

由于交换机设置为基于被覆盖为不同 EtherType 的服务标签查找 VLAN ID,因此 VLAN 过滤仅对数据包的外部标签进行;不会检查内部标签。

镜像


Mirroring

Cloud Router Switch 支持三种类型的镜像。基于端口的镜像可以应用于任何交换机芯片端口,基于 VLAN 的镜像适用于所有指定的 VLAN,与交换机芯片端口无关,基于 MAC 的镜像复制从 Unicast Forwarding Database 中配置的端口可到达的特定设备发送或接收的流量。

基于端口的镜像

第一个配置将 ether5 端口设置为 mirror0 分析器端口,用于入站和出站镜像。镜像流量将被发送到此端口。从 ether6 端口启用基于端口的入站和出站镜像。

/interface/ethernet/switch
set ingress-mirror0=ether5 egress-mirror0=ether5

/interface/ethernet/switch/port
set ether6 ingress-mirror-to=mirror0 egress-mirror-to=mirror0

基于 VLAN 的镜像

第二个示例要求端口在一组中交换。镜像配置将 ether5 端口设置为 mirror0 分析器端口,并设置当从 VLAN 镜像时使用 mirror0 端口。VLAN 表条目仅在 ether2 和 ether7 端口之间的 VLAN 300 流量启用镜像。

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether7 hw=yes

/interface/ethernet/switch
set ingress-mirror0=ether5 vlan-uses=mirror0

/interface/ethernet/switch/vlan
add ports=ether2,ether7 vlan-id=300 learn=yes ingress-mirror=yes

基于 MAC 的镜像

第三个配置还要求端口作为一组交换。镜像配置将 ether5 端口设置为 mirror0 分析器端口,并设置当从 Unicast Forwarding 数据库镜像时使用 mirror0 端口。Unicast Forwarding 数据库中的条目为来自 ether8 端口且源或目标 MAC 地址为 E7:16:34:A1:CD:18 的数据包启用镜像。

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

/interface/ethernet/switch
set ingress-mirror0=ether5 fdb-uses=mirror0

/interface/ethernet/switch/unicast-fdb
add port=ether8 mirror=yes svl=yes mac-address=E7:16:34:A1:CD:18

Trunking


Trunking 3

Cloud Router Switch 中的 Trunking 提供具有硬件自动故障转移和负载均衡的静态链路聚合组。尚不支持 IEEE802.3ad 和 IEEE802.1ax 兼容的链路聚合控制协议。最多支持 8 个 Trunk 组,每个 Trunk 组最多 8 个 Trunk 成员端口。

配置需要一组交换端口以及 Trunk 表中的一个条目:

/interface/bridge
add name=bridge1 protocol-mode=none
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

/interface/ethernet/switch/trunk
add name=trunk1 member-ports=ether6,ether7,ether8

此示例还展示了另一端 RouterOS 中正确的绑定配置:

/interface/bonding
add name=bonding1 slaves=ether2,ether3,ether4 mode=balance-xor transmit-hash-policy=layer-2-and-3

危险

网桥 (R)STP 不知道底层交换机 Trunking 配置,某些 Trunk 端口可能进入丢弃或阻塞状态。当 Trunk 成员端口连接到其他网桥时,你应该禁用 (R)STP 或过滤 Trunk 设备之间的任何 BPDU(例如使用 ACL 规则)。

每个端口的有限 MAC 访问


禁用 MAC 学习并配置静态 MAC 地址,可以控制哪些确切的设备可以与 CRS1xx/2xx 交换机通信以及通过它们通信。

配置需要一组交换端口、在这些端口上禁用 MAC 学习以及静态 FDB 条目:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether6 hw=yes learn=no unknown-unicast-flood=no
add bridge=bridge1 interface=ether7 hw=yes learn=no unknown-unicast-flood=no

/interface/ethernet/switch/unicast-fdb
add mac-address=4C:5E:0C:00:00:01 port=ether6 svl=yes
add mac-address=D4:CA:6D:00:00:02 port=ether7 svl=yes

/interface/ethernet/switch/acl
add action=drop src-mac-addr-state=sa-not-found src-ports=ether6,ether7 table=egress
add action=drop src-mac-addr-state=static-station-move src-ports=ether6,ether7 table=egress

CRS1xx/2xx 交换机还允许每个端口学习一个动态 MAC,以确保无论其 MAC 地址如何,只连接一个最终用户设备:

/interface/ethernet/switch/port
set ether6 learn-limit=1
set ether7 learn-limit=1

隔离


端口级隔离

Port Level Isolation

端口级隔离通常用于 Private VLAN,其中:

  • 一个或多个上行端口在所有用户之间共享,用于访问网关或路由器。
  • 端口组 Isolated Ports 用于访客用户。通信仅通过上行端口。
  • 端口组 Community 0 用于部门 A。允许组成员之间以及通过上行端口通信。
  • 端口组 Community X 用于部门 X。允许组成员之间以及通过上行端口通信。

Cloud Router Switch 使用端口级隔离配置文件来实现 Private VLAN:

  • 上行端口 – 端口级隔离配置文件 0
  • 隔离端口 – 端口级隔离配置文件 1
  • Community 0 端口 - 端口级隔离配置文件 2
  • Community X(X <= 30)端口 - 端口级隔离配置文件 X

此示例需要一组交换端口。假设此示例中使用的所有端口都在一个交换机组中。

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes
add bridge=bridge1 interface=ether9 hw=yes
add bridge=bridge1 interface=ether10 hw=yes

端口隔离配置的第一部分是设置上行端口 – 将 ether2 的端口配置文件设置为 0:

/interface/ethernet/switch/port
set ether2 isolation-leakage-profile-override=0

然后继续在所有隔离端口上设置隔离配置文件 1,并为端口隔离配置文件 1 添加通信端口:

/interface/ethernet/switch/port
set ether5 isolation-leakage-profile-override=1
set ether6 isolation-leakage-profile-override=1

/interface/ethernet/switch/port-isolation
add port-profile=1 ports=ether2 type=dst

设置 Community 2 和 Community 3 端口的配置类似:

/interface/ethernet/switch/port
set ether7 isolation-leakage-profile-override=2
set ether8 isolation-leakage-profile-override=2

/interface/ethernet/switch/port-isolation
add port-profile=2 ports=ether2,ether7,ether8 type=dst

/interface/ethernet/switch/port
set ether9 isolation-leakage-profile-override=3
set ether10 isolation-leakage-profile-override=3

/interface/ethernet/switch/port-isolation
add port-profile=3 ports=ether2,ether9,ether10 type=dst

协议级隔离

Protocol Level Isolation

CRS 交换机上的协议级隔离可用于增强网络安全性。例如,限制用户(ether2、ether3、ether4、ether5)之间的 DHCP 流量并仅允许将其发送到受信任的 DHCP 服务器端口(ether1),可以防止 DHCP 欺骗攻击等安全风险。以下示例展示了如何在 CRS 上配置它。

将所需端口一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether1 hw=yes
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether3 hw=yes
add bridge=bridge1 interface=ether4 hw=yes
add bridge=bridge1 interface=ether5 hw=yes

为所有 DHCP 客户端端口设置相同的 Community 端口配置文件。Community 端口配置文件编号为 2 到 30。

/interface/ethernet/switch/port
set ether2 isolation-leakage-profile-override=2
set ether3 isolation-leakage-profile-override=2
set ether4 isolation-leakage-profile-override=2
set ether5 isolation-leakage-profile-override=2

并为选定的 Community (2) 配置端口隔离/泄漏配置文件,以仅允许目的地为受信任 DHCP 服务器所在端口的 DHCP 流量。注册状态和流量类型属性必须设置为空,以仅对 DHCP 协议应用限制。

/interface/ethernet/switch/port-isolation
add port-profile=2 protocol-type=dhcpv4 type=dst forwarding-type=bridged ports=ether1 registration-status="" traffic-type=""

服务质量(QoS)


QoS 配置方案

基于 MAC 的流量调度与整形:[MAC address in UFDB] -> [QoS Group] -> [Priority] -> [Queue] -> [Shaper]

基于 VLAN 的流量调度与整形:[VLAN id in VLAN table] -> [QoS Group] -> [Priority] -> [Queue] -> [Shaper]

基于协议的流量调度与整形:[Protocol in Protocol VLAN table] -> [QoS Group] -> [Priority] -> [Queue] -> [Shaper]

基于 PCP/DEI 的流量调度与整形:[Switch port PCP/DEI mapping] -> [Priority] -> [Queue] -> [Shaper]

基于 DSCP 的流量调度与整形:[QoS DSCP mapping] -> [Priority] -> [Queue] -> [Shaper]

使用内部 Priority 的基于 MAC 的流量调度

在严格优先级调度模式下,最高优先级队列首先被服务。队列编号代表优先级,队列编号最高的队列具有最高优先级。流量从最高优先级队列传输直到队列为空,然后转到下一个最高优先级队列,依此类推。如果出站端口不存在拥塞,数据包在收到后立即传输。如果在持续有高优先级流量的端口发生拥塞,较低优先级的队列将饥饿。

在所有 CRS 交换机上,根据内部 Priority 进行基于 MAC 的出站流量调度的方案如下:[MAC address] -> [QoS Group] -> [Priority] -> [Queue];
在此示例中,host1(E7:16:34:00:00:01)和 host2(E7:16:34:00:00:02)在端口 ether7 上的传输流量将具有较高优先级 1,其余主机将具有较低优先级 0。注意 CRS 每个端口最多有 8 个队列。

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

创建用于 UFDB 的 QoS 组:

/interface/ethernet/switch/qos-group
add name=group1 priority=1

添加 UFDB 条目以匹配 ether7 上的特定 MAC 并应用 qos group1:

/interface/ethernet/switch/unicast-fdb
add mac-address=E7:16:34:00:00:01 port=ether7 qos-group=group1 svl=yes
add mac-address=E7:16:34:00:00:02 port=ether7 qos-group=group1 svl=yes

配置 ether7 端口队列以仅针对目标地址按严格优先级和 QoS 方案工作:

/interface/ethernet/switch/port
set ether7 per-queue-scheduling="strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0" priority-to-queue=0:0,1:1 qos-scheme-precedence=da-based

使用内部 Priority 的基于 MAC 的流量整形

根据内部 Priority 进行基于 MAC 的流量整形的方案如下:[MAC address] -> [QoS Group] -> [Priority] -> [Queue] -> [Shaper];
在此示例中,无限流量将具有优先级 0,受限流量将具有优先级 1,带宽限制为 10Mbit。注意 CRS 每个端口最多有 8 个队列。

创建用于交换的端口组:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

创建用于 UFDB 的 QoS 组:

/interface/ethernet/switch/qos-group
add name=group1 priority=1

添加 UFDB 条目以匹配 ether8 上的特定 MAC 并应用 QoS group1:

/interface/ethernet/switch/unicast-fdb
add mac-address=E7:16:34:A1:CD:18 port=ether8 qos-group=group1 svl=yes

配置 ether8 端口队列以仅针对目标地址按严格优先级和 QoS 方案工作:

/interface/ethernet/switch/port
set ether8 per-queue-scheduling="strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0" priority-to-queue=0:0,1:1 qos-scheme-precedence=da-based

对 ether8 上的 queue1 应用带宽限制:

/interface/ethernet/switch/shaper
add port=ether8 rate=10M target=queue1

如果 CRS 交换机支持访问控制列表,则此配置更简单:

/interface/ethernet/switch/acl/policer
add name=policer1 yellow-burst=100k yellow-rate=10M

/interface/ethernet/switch/acl
add mac-dst-address=E7:16:34:A1:CD:18 policer=policer1

使用内部优先级的基于 VLAN 的流量调度 + 整形

最佳实践是为受 shaper 限制的流量分配较低的内部 QoS Priority,以使其在严格优先级调度器中也变得不那么重要。(较高优先级应更重要且不受限制)

在此示例中:
交换机端口 ether6 使用 shaper 限制来自 ether7 和 ether8 的流量。
当链路达到其容量时,具有最高优先级的流量将首先发送出去。
VLAN10 -> QoS group0 = 最低优先级
VLAN20 -> QoS group1 = 正常优先级
VLAN30 -> QoS group2 = 最高优先级

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether6 hw=yes
add bridge=bridge1 interface=ether7 hw=yes
add bridge=bridge1 interface=ether8 hw=yes

创建用于 VLAN 表的 QoS 组。

/interface/ethernet/switch/qos-group
add name=group0 priority=0
add name=group1 priority=1
add name=group2 priority=2

添加 VLAN 条目以为特定 VLAN 应用 QoS 组。

/interface/ethernet/switch/vlan
add ports=ether6,ether7,ether8 qos-group=group0 vlan-id=10
add ports=ether6,ether7,ether8 qos-group=group1 vlan-id=20
add ports=ether6,ether7,ether8 qos-group=group2 vlan-id=30

配置 ether6、ether7 和 ether8 端口队列以仅针对基于 VLAN 的 QoS 按严格优先级和 QoS 方案工作。

/interface/ethernet/switch/port
set ether6 per-queue-scheduling="strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0" priority-to-queue=0:0,1:1,2:2 qos-scheme-precedence=vlan-based
set ether7 per-queue-scheduling="strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0" priority-to-queue=0:0,1:1,2:2 qos-scheme-precedence=vlan-based
set ether8 per-queue-scheduling="strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0" priority-to-queue=0:0,1:1,2:2 qos-scheme-precedence=vlan-based

在 ether6 上应用带宽限制。

/interface/ethernet/switch/shaper
add port=ether6 rate=10M

基于 PCP 的流量调度

默认情况下,CRS1xx/CRS2xx 系列设备将忽略 PCP/CoS/802.1p 值并以 FIFO(先进先出)方式转发数据包。当设备内部队列未满时,数据包以 FIFO 方式发送,但一旦某个队列填满,较高优先级的流量就可以首先发送出去。让我们考虑一个场景,其中 ether1 和 ether2 正在向 ether3 转发数据,但当 ether3 拥塞时,数据包将被调度。我们可以配置交换机保持最低优先级数据包,直到所有较高优先级数据包发送完毕。这是 VoIP 类型设置中非常常见的场景,其中某些流量需要优先处理。

要实现这种行为,将 ether1、ether2 和 ether3 端口一起交换:

/interface/bridge
add name=bridge1
/interface/bridge/port
add bridge=bridge1 interface=ether1 hw=yes
add bridge=bridge1 interface=ether2 hw=yes
add bridge=bridge1 interface=ether3 hw=yes

为每个端口上的每个内部队列启用严格策略:

/interface/ethernet/switch/port
set ether1,ether2,ether3 per-queue-scheduling="strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0,strict-priority:0"

将每个 PCP 值映射到内部优先级值,为方便起见,简单地将 PCP 到内部优先级 1 对 1 映射:

/interface/ethernet/switch/port
set ether1,ether2,ether3 pcp-based-qos-priority-mapping=0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7

由于交换机将首先清空最大的队列,而你需要最高优先级首先被服务,因此你可以将此内部优先级 1 对 1 分配给队列:

/interface/ethernet/switch/port
set ether1,ether2,ether3 priority-to-queue=0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7

最后,设置每个交换机端口基于 PCP 值调度数据包:

/interface/ethernet/switch/port
set ether1,ether2,ether3 qos-scheme-precedence=pcp-based

带宽限制


Ingress Port policer 和 Shaper 都为 CRS 交换机提供带宽限制功能。

  • Ingress Port Policer 在端口上设置 RX 限制:
/interface/ethernet/switch/ingress-port-policer
add port=ether5 meter-unit=bit rate=10M
  • Shaper 在端口上设置 TX 限制。
/interface/ethernet/switch/shaper
add port=ether5 meter-unit=bit rate=10M

流量风暴控制


同样的 Ingress Port policer 也可用于流量风暴控制,以防止由广播、多播或单播流量风暴引起的二层端口中断。

  • ether5 端口上每秒 500 个数据包限制的广播风暴控制示例:
/interface/ethernet/switch/ingress-port-policer
add port=ether5 rate=500 meter-unit=packet packet-types=broadcast  
  • 包含 ARP 和 ND 协议以及未注册多播流量的多种数据包类型示例。未注册多播是未在多播转发数据库中定义的流量。
/interface/ethernet/switch/ingress-port-policer
add port=ether5 rate=5k meter-unit=packet packet-types=broadcast,arp-or-nd,unregistered-multicast

另请参阅