通知 爱刷机 路由器教程 →→《值得买》 ←←

新版openwrt没有交换机vlan选项使用dsa驱动方式显示交换机(VLAN)选项

2022-05-07
0评论
/
阅读
爱搜啊

现在的新版的openwrt固件(比如openwrt 21.02)已经找不到新版没有交换机(VLAN)了,在网上找了半天,发现好多人再问,就是没有解决方案。

现在分享一下新版的openwrt固件如何找到打开VLAN交换机功能。

新版openwrt没有vlan交换机选项

新版openwrt固件找不到交换机选项

由于在openwrt21.02交换机设置换成了dsa模式,原有的swconfig 没有了, 在接口菜单上就没有了交换机选项。 现在4个端口,都被做成了独立的lan1,lan2,lan3,lan4

在端口菜单,增加了一个设备子菜单, 在里面可以用网桥来分配端口, 另外生成树协议(Spanning Tree Protocol),也从接口改到了设备目录下,从17版升级到DSA模式21版的时候, 除了VLAN设置会丢失外, STP设置也会丢失, 如果启用了mesh的话, STP设置没了,就可能会造成网络瘫痪。

新版openwrt固件设置vlan-id

新的vlan-id设置, 在[网络]->[接口]->[设备]->br-lan->[配置...]->[网桥vlan过滤]->[新增]->输入van-id

DSA驱动与swconfig驱动介绍

DSA 代表分布式交换机架构,是用于网络交换机的 Linux 内核子系统。它是 OpenWrt 的 swconfig 框架的上游替代品,许多新路由器使用 DSA 驱动程序而不是 swconfig 驱动程序。

在 DSA 中,每个交换机端口都是一个单独的 Linux 接口。这意味着ip/ifconfig命令将显示接口等lan1,lan2,wan等。

DSA 交换机端口可以用作独立接口(WAN 的通用解决方案),也可以使用 Linux 桥接接口进行桥接。在后一种情况下,交换机仍然能够在硬件级别路由流量,因此不会影响性能。

每个端口最多只能是一个网桥的一部分。

在网络菜单下显示交换机(VLAN)选项的方法

编辑  /etc/config/network 

添加以下参数

config switch
                option name 'switch0'
                option reset '1'
                option enable '1'
#打开 switch 交换功能

config switch_vlan
          option device 'switch0'
          option vlan '0'
          option ports " 0 1 2 3 6t"    
          option vid '0'
          
#port0、1、2、3口属于vlan 0;第6个口是eth0 (CPU)网口 truck 类型口

reboot #重启

使用命令简单的设置桥接

简单的端口桥接

在最简单的情况下,交换机端口使用 Linux 桥接接口进行桥接,OpenWrt 使用 IP 协议配置该接口。

在这种情况下,连接到桥接端口的所有设备都可以相互通信,也可以与路由器本身通信。

例子:


config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask'255.255.255.0'

多个网络(使用网桥)

通过使用多个桥接接口,可以将交换机设置为将选定的端口分组到单独的网络中。使用分离的防火墙区域,连接到不同端口组的设备将无法相互通信。

例子:



config device
        option name 'br-home'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
config device
        option name 'office'
        option type 'bridge'
        list ports 'lan3'
        list ports 'lan4'
config interface 'home'
        option device 'br-home'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask'255.255.255.0'
config interface 'office'
        option device 'office'
        option proto 'static'
        option ipaddr '192.168.13.1'
        option netmask'255.255.255.0'

多个网络(使用 VLAN)

还可以使用具有多个 VLAN 的单个网桥来分隔(分组)端口。这需要将接口分配给正确的软件 VLAN。

例子:


config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
config bridge-vlan
        option device 'br-lan'
        option vlan '1'
        list ports 'lan1'
        list ports 'lan2'
config bridge-vlan
        option device 'br-lan'
        option vlan '2'
        list ports 'lan3'
        list ports 'lan4'
config interface 'home'
        option device 'br-lan.1'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask'255.255.255.0'
config interface 'office'
        option device 'br-lan.2'
        option proto 'static'
        option ipaddr '192.168.13.1'
        option netmask'255.255.255.0'

VLAN 标记的流量

通过正确的桥接 VLAN 配置,选定端口也可以使用 VLAN 标记的流量。它还需要将 OpenWrt 接口分配给正确的软件 VLAN。

例子:

端口lan4使用 VLAN 1 的标记数据包并具有 PVID 2。


config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
config bridge-vlan
        option device 'br-lan'
        option vlan '1'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4:t'
config bridge-vlan
        option device 'br-lan'
        option vlan '2'
        list ports 'lan4:u*'
config interface 'lan'
        option device 'br-lan.1'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask'255.255.255.0'



点击链接加入群聊三群:751529538

点击链接加入群聊二群:376877156

点击链接加入群聊【路由器交流群:622891808已满】

本站附件分享,如果附件失效,可以去找找看

诚通网盘附件百度网盘附件


饿了么红包

饿了么红包

于2022-05-07发布