RouterOS 日常改操作逻辑,尤其是 6.41 开始原来 Switch 菜单内容缩水他又改回去了,功能开始移动到 Bridge 菜单并且自动判断是否开启硬件加速以后,只能说越来越看不懂了。下面简单介绍一个 RouterOS 新版 Bridge 菜单的 VLAN 设置。
为了便于理解,本文统一使用 Cisco VLAN 记法:
- 连接非交换设备,需要添加、移除 VLAN 标记的端口称为 access 端口;
- 连接交换设备,不需要操作 VLAN 标记的端口称为 trunk 端口。
另外有一点需要注意的是,虽然 vlan-ids 是个列表,但是不建议一列里面写多个 VLAN ID,因为 untag 的时候会出问题。
纯二层交换
|
/interface bridge add name=bridge1 /interface bridge port add port=ether1 bridge=bridge1 add port=ether2 bridge=bridge1 add port=ether3 bridge=bridge1 add port=ether4 bridge=bridge1 |
二层 VLAN
端口隔离
有的时候你只是想让 ether1 和 ether2 之间、ether3 和 ether4 之间交换数据。如果你添加两个 bridge interface 然后把它们分别加入各自的 bridge,那么在大多数 RouterOS 硬件上,至少有一个 bridge 是无法启用硬件转发功能的。高效的实现方法是这样的:
|
/interface bridge add name=bridge1 /interface bridge vlan add bridge=bridge1 vlan-ids=100 add bridge=bridge1 vlan-ids=200 /interface bridge port add port=ether1 bridge=bridge1 pvid=100 add port=ether2 bridge=bridge1 pvid=100 add port=ether3 bridge=bridge1 pvid=200 add port=ether4 bridge=bridge1 pvid=200 /interface bridge set [find name=bridge1] vlan-filtering=yes |
这样,在支持 VLAN 功能的交换芯片上,RouterOS 可以对所有端口都启用硬件转发。
VLAN Trunking
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
/interface bridge add name=bridge1 # 下面 port 配置里的 pvid 会导致 port 自动加进对应 vlan 的 untagged 列表 # 这里只需要写 tagged 列表就行了 /interface bridge vlan add bridge=bridge1 tagged="trunk1,trunk2" vian-ids=100 add bridge=bridge1 tagged="trunk1,trunk2" vian-ids=200 /interface bridge port add port=trunk1 bridge=bridge1 add port=trunk2 bridge=bridge1 add port=access1 bridge=bridge1 pvid=100 add port=access2 bridge=bridge1 pvid=100 add port=access3 bridge=bridge1 pvid=200 /interface bridge set [find name=bridge1] vlan-filtering=yes |
注意:
三层 VLAN
RouterOS 作为路由器实现跨 VLAN 路由,或者交换机需要在 VLAN 上进行 IP 通信(例如用作管理)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
/interface bridge add name=bridge1 # 注意这里 tagged port 需要加上 bridge1,这样 CPU 才能收到带 tag 的包 /interface bridge vlan add bridge=bridge1 tagged="bridge1,trunk1,trunk2" vian-ids=100 add bridge=bridge1 tagged="bridge1,trunk1,trunk2" vian-ids=200 /interface bridge port add port=trunk1 bridge=bridge1 add port=trunk2 bridge=bridge1 add port=access1 bridge=bridge1 pvid=100 add port=access2 bridge=bridge1 pvid=100 add port=access3 bridge=bridge1 pvid=200 # 创建三层 VLAN interface /interface vlan add name=vlan100 interface=bridge1 vlan-id=100 add name=vlan200 interface=bridge1 vlan-id=200 # 接下来就可以在三层 VLAN interface 上配置三层功能 /ip address add 10.0.0.1/24 interface=vlan100 /ip dhcp-client add interface=vlan200 disabled=no /interface bridge set [find name=bridge1] vlan-filtering=yes |
参考:
大哥能帮忙配置下 ROS 吗 电信 ros vlan
大哥, 你 QQ 或微信是多少? 我遇见难题了, 求救。 。 。