我的博客

a

网络配置:拆出 WAN 口

修改文件:/etc/config/network

问题:list ports 'eth0' 把 eth0 绑进了 br-lan,所以没有 WAN 口。

一、一次性改好(网络 + DNS 一处完成)

config device
        option name 'br-lan'
        option type 'bridge'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        list ipaddr '192.168.1.1/24'
        option ipassign '60'

config interface 'wan'
        option device 'eth0'
        option proto 'dhcp'
        list dns '8.8.8.8'
        list dns '114.114.114.114'

相比原文件:删掉 list ports 'eth0',新增 wan 段(含 DNS)。

二、一次性验证

/etc/init.d/network restart
ip a                # eth0 = NAT网段IP,br-lan 仍为 192.168.1.1
ping 8.8.8.8        # 不通 = IP 层问题
ping baidu.com      # IP 通但域名不通 = DNS 问题
apk update

三、LAN 网桥验证

OpenWrt 内执行 brctl show,interfaces 列出全部网口即添加成功:

br-lan    ...    no    eth3
                     eth1
                     eth2

STP enabled no:未开生成树,虚拟机环境没问题。

宿主机侧操作:

  1. Ubuntu 网卡连到 eth1/eth2/eth3 对应的桥接网络
  2. Ubuntu 拿到 192.168.1.x IP
  3. 连接:
ssh root@192.168.1.1

LAN 默认放行 22 端口,无需改防火墙。