娱乐新地带论坛

娱乐新地带论坛 (https://bbs.1819.net/index.php)
-   『网络家园』 (https://bbs.1819.net/forumdisplay.php?f=13)
-   -   RouterOS 6.41以后版本基于端口的的VLAN设置方法 (https://bbs.1819.net/showthread.php?t=79162)

Tony 2019-06-21 02:40 PM

RouterOS 6.41以后版本基于端口的的VLAN设置方法
 
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

代码:

/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

注意:

不要在bridge上创建VLAN interface然后将VLAN interface添加到新的bridge里
不要在每个trunk interface上创建VLAN interface然后把相同VLAN的VLAN interface给bridge起来
三层VLAN
RouterOS作为路由器实现跨VLAN路由,或者交换机需要在VLAN上进行IP通信(例如用作管理)。

代码:

/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



所有时间均为北京时间。现在的时间是 07:37 AM

©2003-2024 1819.net All rights reserved. © 2024