找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 15790|回复: 6

外网防火墙端口转发失败的可以参考一下我的解决事例

[复制链接]
发表于 2015-3-10 15:53 | 显示全部楼层 |阅读模式
本帖最后由 rappleboy 于 2015-3-10 16:01 编辑

家里有主路由网件4300和监控器路由 buffalo wzr-hp-300nh2两台,主路由联联通光线,监控路由192.168.1.100通过局域网连接主路由192.168.1.1,192.168.1.0网段内。 主要希望在单位能外网远程连接和管理监控路由。
防火墙打开主路由的WEB远程和SSH远程比较顺利:
在/etc/config/firewall文件中加入
config rule
        option target 'ACCEPT'
        option src 'wan'
        option proto 'tcp'
        option dest_port '8085'
        option name 'web'


config redirect
        option target 'DNAT'
        option src 'wan'
        option dest 'lan'
        option proto 'tcp udp'
        option src_dport '8085'
        option dest_ip '192.168.1.1'
        option dest_port '80'
        option name '8085'


config redirect
        option target 'DNAT'
        option src 'wan'
        option dest 'lan'
        option proto 'tcp'
        option src_dport '22'
        option dest_ip '192.168.1.1'
        option dest_port '22'
        option name 'ssh'


/etc/init.d/firewall restart  后成功远程打开

但是打开监控路由192.168.1.100的8080监控WEB端口却怎么也不成功。
config rule
        option target 'ACCEPT'
        option src 'wan'
        option proto 'tcp udp'
        option dest_port '8080'
        option name '8080'


config redirect
        option target 'DNAT'
        option src 'wan'
        option dest 'lan'
        option proto 'tcp'
        option src_dport '8080'
        option dest_ip '192.168.1.100'
        option dest_port '8080'
        option name 'jiankong'


打开http://DDNS:8080 总是显示网页无法打开。刚开始以为格式写的问题,但发现同样的写法,映射到一台电脑的UltraVNC的5900端口是可以正常打开和远程控制成功的。
于是在恩山和openwrt各种搜索和尝试,各种无果,各种失败,最后还是在openwrt的wiki里http://wiki.openwrt.org/doc/uci/firewall查到一个小讨厌
Masquerading on lan
The router 2 cannot reply to those packets because we didn't adjust its routing table, that is we didn't specify that the gateway to reply to "wan" sources is the router 1. Indeed those redirected packets will have an source ip external from the (default) "lan" zone 192.168.1.0/24.
We can solve this activating the masquerading on the "lan" zone on the router 1, in this way.

config zone
        option name 'lan'
        list network 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        option masq '1'

尝试着加入firewall, restart, 远程访问一下,我去,一看状态栏反应我就知道成功了,这个小讨厌让我耗费了一天时间阿,终于可以出去看看阳光了拉
总结一下,一般的端口映射是router->pc的,pc是终端用户,可以正常返回package, 但是router->router的端口映射比较特殊,目的router不可以直接返回package,需要在主路由的lan zone里设置允许冒充假pc来获得映射。



最后感谢一下 明月永在  rapistor, 两个路由都是用的他制作的openwrt 固件,很不错

我的恩山、我的无线 The best wifi forum is right here.
发表于 2015-3-10 16:36 | 显示全部楼层
我的情况跟你类似:


不要说端口转发或打开路由器端口,都不行。
目前端口转发到其他子IP都是可以的:
192.168.1.1 82 to 80 路由 no
192.168.1.2 83 to 80... 其他任何设备 yes
192.168.1.3 84 to 80... 其他任何设备 yes
查看防火墙状态,有点不同
4 0 0.00 B REDIRECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:82 /* LYA */ redir ports 80
5 0 0.00 B REDIRECT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:82 /* LYA */ redir ports 80
6 0 0.00 B DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:83 /* LYB */ to:192.168.1.2:80
7 0 0.00 B DNAT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:83 /* LYB */ to:192.168.1.2:80

求解???
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2015-3-10 17:42 | 显示全部楼层
搞定,自己解决!

点评

怎么解决的。我现在80口可以过去,22口不行  详情 回复 发表于 2016-5-13 14:39
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-5-13 14:39 | 显示全部楼层
toabin 发表于 2015-3-10 17:42
搞定,自己解决!

怎么解决的。我现在80口可以过去,22口不行
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-7-21 08:32 | 显示全部楼层
外网防火墙端口转发失败的可以参考一下我的解决事例

点评

挖坟请教是哪个帖子?我找了一下没找到…… 现在也是端口转发无效,头疼…… 之前用koolshare的很容易。  详情 回复 发表于 2019-11-18 22:07
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-11-1 21:27 | 显示全部楼层
感谢,原来如此 ,主要是option masq '1' 这个参数起作用,在luci界面的防火墙里,把lan到wan的“IP 动态伪装”钩上就可以了。终于解决了主路由端口转发到二级路由的问题。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-11-18 22:07 | 显示全部楼层
wsydd 发表于 2016-7-21 08:32
外网防火墙端口转发失败的可以参考一下我的解决事例

挖坟请教是哪个帖子?我找了一下没找到…… 现在也是端口转发无效,头疼…… 之前用koolshare的很容易。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-3-28 21:35

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表