关于新版openwrt配置网桥,绕过此路由器直接获取上级ip的方法

前言

笔者这里有多层的网络,现在需要绕过某个openwrt路由器,直接获取上层路由的ip。简单的办法是重新拉一根网线或者安装一个单独的交换机,但是不现实,所幸可以通过虚拟交换机来实现。

在旧版openwrt中,可以通过网络–交换机中划分vlan来实现。但是在新版openwrt的一些固件中,在网络菜单已经没有了交换机这个选择项,这是因为新的版本已经不支持swconfig配置vlan,更改为dsa配置dot1q网络。

正文

但是还是有解决办法的。

例如,下列 /etc/config/network 配置文件可以将wan口和lan1口划分到网桥br_wan,lan2口,lan3口,lan4口划分到网桥br_lan,达到了vlan的目的。现在,我可以在lan1接口上插网线,绕过本路由,直接获取到上级路由的ip了。

config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config globals 'globals'
option packet_steering '1'
option ula_prefix 'fd49:2eb8:6982::/48'

config device
option name 'br-lan'
option type 'bridge'
list ports 'lan2'
list ports 'lan3'
list ports 'lan4'

config interface 'lan'
option device 'br-lan'
option proto 'static'
option netmask '255.255.255.0'
option ip6assign '60'
option ipaddr '192.168.19.1'

config device
option name 'br-wan'
option type 'bridge'
list ports 'wan'
list ports 'lan1'

config interface 'wan6'
option device 'br-wan'
option proto 'dhcpv6'

config interface 'wan'
option device 'br-wan'
option proto 'dhcp'

扩展:在 DSA 中,每个物理的端口都变成是一个单独的 Linux 接口,所以 ip/ifconfig 命令将直接显示接口lan1,lan2,wan等,不再显示eth0,eth1等等。

参考

https://forum.openwrt.org/t/mini-tutorial-for-dsa-network-config/96998

https://www.right.com.cn/forum/thread-5807504-1-1.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

10 + 19 =