如意云-莘家小站
  • 首页
  • 友链
  • 关于
如意云-莘家小站
这是一个记录生活和技术学习的个人博客.
  1. 首页
  2. 网络与系统
  3. 正文

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

2023年2月17日 8536点热度 4人点赞 0条评论

索引

Toggle
  • 前言
  • 正文
  • 参考

前言

笔者这里有多层的网络,现在需要绕过某个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

本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可
标签: 遇到问题
最后更新:2024年12月27日

jiawei

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复
  • Emby
  • Synology
  • Unraid
  • 文段分享
  • 生产力小工具
  • 生活记录
  • 程序开发实例
  • 网络与系统
  • 逆向工程
  • 遇到问题

2019-2025

Theme Kratos Made By Seaton Jiang

冀ICP备18022758号-2

冀公网安备13072802000034号