1 fat00119 2023-05-02 16:13:45 +08:00 via Android 端口回流 |
![]() | 2 opengps 2023-05-02 16:23:33 +08:00 via Android 有的路由器确实会内部访问不到自己外部端口 |
![]() | 3 crab 2023-05-02 16:49:33 +08:00 |
4 Archeb 2023-05-02 19:25:38 +08:00 需要做 Hairpin NAT ,也就是端口回流,可能是你的路由器固件没有自动实现这个功能。 |
![]() | 5 opengps 2023-05-02 19:43:58 +08:00 对了,我当时变通解决,用 hosts 强制指定域名解析到内网指定的机器 |
![]() | 6 K8dcnPEZ6V8b8Z6 OP @Archeb 事实上好像没这个功能…… |
![]() | 7 K8dcnPEZ6V8b8Z6 OP |
8 handshake 2023-05-04 15:32:34 +08:00 防火墙添加一条 nat 规则,转换源地址为内部网段即可 |
9 tkyb123 2023-05-05 14:13:46 +08:00 小米路由器同样遇到了这样的问题。。。不知道如何解决,求大神指点 |
![]() | 10 ziwen1943 2023-05-05 15:38:17 +08:00 端口回源没配置吧,我以前也遇到过这种问题,一般是对应的防火墙或者负载均衡加 NAT 或者回源规则就好。 |
11 busier 2023-05-05 19:21:22 +08:00 RouterOS 也遇到这个问题!网上找的解决脚本也是错误一堆!好在自己慢慢改搞定了! |
![]() | 12 filtrate 2023-05-05 19:57:51 +08:00 tp 企业路由是在 NAPT 设置源地址,但是我用过的 tp 路由上这个功能没一个正常的 |
13 dont39 2023-05-06 11:39:38 +08:00 如果有 ipv6 地址的话,可以在域名解析那边加上设备的 ipv6 地址,内网的机器通过域名访问的时候会优先走 ipv6 从而绕过这个问题。 |
![]() | 15 K8dcnPEZ6V8b8Z6 OP @jinqzzz 我后面解决了,是问客服要了另一个版本的固件,没想到更新后就可以了 |
16 busier 2023-05-07 20:21:15 +08:00 @raycheung Router OS 端口映射,支持回流 /ip firewall nat add action=src-nat chain=srcnat comment=SNAT to-addresses=111.175.157.94 add action=dst-nat chain=dstnat comment=HairpinNAT dst-address=111.175.157.94 dst-port=21194 protocol=udp to-addresses=192.168.88.2 to-ports=21194 add action=dst-nat chain=dstnat comment=HairpinNAT dst-address=111.175.157.94 dst-port=8443 protocol=tcp to-addresses=192.168.88.201 to-ports=8443 说明:action=src-nat 规则行设置 NAT ,action=dst-nat 规则行设置支持回流的端口映射 其中 111.175.157.94 为公网 IP ,这里可以不手动修改,利用下面的脚本自动修改! 特别注意的是,注释:comment 指令不能省略,下面的脚本根据这个来更新规则的! ================================================ Router OS 自动更新上面规则中公网 IP 的脚本 :global ipaddr [/ip address get [/ip address find interface="pppoe-out1"] address]; :set ipaddr [:pick $ipaddr 0 ([len $ipaddr]-3)]; :global oldip [/ip firewall nat get [/ip firewall nat find chain=srcnat action=src-nat] to-addresses]; :if ($ipaddr != $oldip) do={ /ip firewall nat set [/ip firewall nat find chain=srcnat action=src-nat comment="SNAT"] to-addresses=$ipaddr; /ip firewall nat set [/ip firewall nat find chain=dstnat action=dst-nat comment="HairpinNAT"] dst-address=$ipaddr; } 将此脚本放到 RouterOS 中运行,其中 pppoe-out1 是 PPPoE 拨号接口的名字! 这个脚本从 pppoe-out1 接口获取公网 IP ,然后去 firewall nat 表更新 comment="SNAT" 和 comment="HairpinNAT" 规则中的公网 IP 设置这个脚本在 RouterOS 中每 10 分钟运行一下就可以了,完美解决 RouterOS 回流问题! 就是这么简单! |
![]() | 18 fastcache 2023-05-08 15:45:48 +08:00 @raycheung 不用脚本的配置 /ip firewall nat add action=masquerade chain=srcnat comment="Hairpin NAT" connection-mark=Hairpin-NAT /ip firewall mangle add action=mark-connection chain=prerouting comment="Mark connections for hairpin NAT" dst-address-list=wan-ip new-connection-mark=Hairpin-NAT passthrough=yes src-address-list=LANs |
20 busier 2023-05-08 21:52:00 +08:00 @fastcache 你的配置中 dst-address-list=wan-ip ,如果是 PPPoE 动态获得地址,你的 wan-ip 这个地址列表如何更新? |
![]() | 21 fastcache 2023-05-08 23:38:07 +08:00 |
23 xPKK1qofAr6RR09O 2023-05-09 12:08:38 +08:00 @raycheung 楼上都过于复杂了...只需要一条配置 /ip firewall nat add action=masquerade chain=srcnat src-address=192.168.1.0/24 dst-address=192.168.1.0/24 out-interface=LAN 192.168.1.0/24 换成你的内网段 out-interface 换成你的内网端口或桥 |