当NAT内部的设备访问内网由路由的外界IP port forward过来的TCP端口的时候

已经想不到更短的标题了。问题简单描述就是兴冲冲把家里路由的外部IP绑定了动态dns,然后port forward到树莓派上。
装上了owncloud服务,挂上大硬盘,嗯不错。
可是一回家就傻眼了。

突然发现自己家里的电脑肿么都连不上树莓派上的owncloud。 手机切了wifi就又连上了。这是为什么呢?

为什么呀

答案纯引用。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 The problem here is, that your router does not NAT your internal client's address. Thus, the TCP handshake fails.

Let's assume following IPs

Client: 192.168.1.3
Server: 192.168.1.2
Router internal: 192.168.1
Router external: 123.123.123.1
Here is what is happening:

Client (192.168.1.3) sends TCP-SYN to your external IP, Port 80 (123.123.123.1:80)
Router sees port forwarding rule and forwards the packet to the server (192.168.1.2:80) without changing the source IP (192.168.1.3)
Client waits for a SYN-ACK from the external IP
Server send his answer back to the client directly, because it's on the same subnet. It does not send the packet to the router, which would reverse the NAT.
Client recieves a SYN-ACK from 192.168.1.2 instead of 123.123.123.1. And discards it.
Client still waits for a SYN-ACK from 123.123.123.1 and times out.

该肿么办

pc的话在 /etc/hosts里将绑定的host直接指定给内网ip。

手机该肿么办?谁来告诉我啊。

NAT