coolsnowwolf / lede

Lean's LEDE source
Other
29.84k stars 19.53k forks source link

端口转发后无法在路由器本机访问 #12372

Open Co1lin opened 3 months ago

Co1lin commented 3 months ago

详细叙述

Router (10.0.0.1) -> Ubuntu (10.0.0.122, 在 54321 监听 HTTP) Router 上设置端口转发从 wan 到 10.0.0.122:54321 之后,

重复 issue

具体型号

x86_64, 自编译 OpenWrt R22.11.11

详细日志

root@OpenWrt:~# iptables-save | grep 54321
-A zone_lan_postrouting -s 10.0.0.0/8 -d 10.0.0.122/32 -p tcp -m tcp --dport 54321 -m comment --comment "!fw3: test (reflection)" -j SNAT --to-source 10.0.0.1
-A zone_lan_postrouting -s 10.0.0.0/8 -d 10.0.0.122/32 -p udp -m udp --dport 54321 -m comment --comment "!fw3: test (reflection)" -j SNAT --to-source 10.0.0.1
-A zone_lan_prerouting -s 10.0.0.0/8 -d 192.168.1.3/32 -p tcp -m tcp --dport 54321 -m comment --comment "!fw3: test (reflection)" -j DNAT --to-destination 10.0.0.122:54321
-A zone_lan_prerouting -s 10.0.0.0/8 -d 192.168.1.3/32 -p udp -m udp --dport 54321 -m comment --comment "!fw3: test (reflection)" -j DNAT --to-destination 10.0.0.122:54321
-A zone_lan_prerouting -s 10.0.0.0/8 -d 公网IP/32 -p tcp -m tcp --dport 54321 -m comment --comment "!fw3: test (reflection)" -j DNAT --to-destination 10.0.0.122:54321
-A zone_lan_prerouting -s 10.0.0.0/8 -d 公网IP/32 -p udp -m udp --dport 54321 -m comment --comment "!fw3: test (reflection)" -j DNAT --to-destination 10.0.0.122:54321
-A zone_wan_prerouting -p tcp -m tcp --dport 54321 -m comment --comment "!fw3: test" -j DNAT --to-destination 10.0.0.122:54321
-A zone_wan_prerouting -p udp -m udp --dport 54321 -m comment --comment "!fw3: test" -j DNAT --to-destination 10.0.0.122:54321
wushenghn commented 3 months ago

访问公网地址的时候做一个源nat,随便转换成一个和内外网不一个网段的地址就可以了

Co1lin commented 3 months ago

@wushenghn 感谢回复!请问可以提供一个具体的命令示例吗?

Co1lin commented 3 months ago

@wushenghn 尝试做了一个 -A zone_wan_postrouting -d 公网IP/32 -m comment --comment "!fw3: snat" -j SNAT --to-source 8.8.4.4 ,但还是 connection refused 。