menu Chancel's blog
rss_feed
Chancel's blog
有善始者实繁,能克终者盖寡。

Docker运行Openwrt旁路由无法联网问题解决

作者:Chancel Yang, 创建:2022-04-29, 字数:1614, 已阅:483, 最后更新:2022-04-29

这篇文章更新于 726 天前,文中部分信息可能失效,请自行甄别无效内容。

一直使用Docker ARM版的Openwrt作为旁路由,在某次重新运行之后发现无法正常联网,进入容器内查看网络

Bash
/ # ping 223.5.5.5
PING 223.5.5.5 (223.5.5.5): 56 data bytes
64 bytes from 223.5.5.5: seq=0 ttl=117 time=8.676 ms
64 bytes from 223.5.5.5: seq=1 ttl=117 time=9.007 ms
64 bytes from 223.5.5.5: seq=2 ttl=117 time=8.177 ms
64 bytes from 223.5.5.5: seq=3 ttl=117 time=8.491 ms
^C
--- 223.5.5.5 ping statistics 4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 8.177/8.587/9.007 ms
/ # nslookup www.chancel.me
Server:         127.0.0.11
Address:        127.0.0.11:53

Non-authoritative answer:
Name:   www.chancel.me
Address: 104.160.18.230

可以看到Openwrt本身的网络没有任何问题,但是非常奇怪的是其他设备都无法通过旁路由联网

在防火墙处添加以下规则,并允许网络转发的情况下问题依旧存在

Bash
iptables -t nat -I POSTROUTING -j MASQUERADE

查阅资料后尝试解除接口设置中lan网口对eth0的桥接,但是解除之后就无法正常访问openwrt

转换思路,换个网络并且找了一台X86的Docker,安装并运行的Docker后发现能正常联网

检查其网络配置,发现同样是 解除接口设置中lan网口对eth0的桥接,ARM版本的配置中缺少了2项 _orig_ifnameoption _orig_bridge,加入后重启便正常了,配置如下

Bash
/ # cat /etc/config/network 

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

config globals 'globals'
        option ula_prefix 'fd13:c13b:3718::/48'

config interface 'lan'
        option proto 'static'
        option netmask '255.255.255.0'
        option ipaddr '192.168.1.100'
        option gateway '192.168.1.1'
        option dns '192.168.1.1'
        option _orig_ifname 'eth0' # Openwrt有时保存后会丢失该项,可手动填入并重启网络
        option _orig_bridge 'true' # Openwrt有时保存后会丢失该项,可手动填入并重启网络
        option ifname 'eth0'

[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]