我有一個在 Raspberry P 上運行的 Apache 伺服器,它在本地網路中運行得很好。在轉送連接埠 80 並嘗試使用公用 IP 進行連線後,Chrome 顯示 ERR_CONNECTION_REFUSED。但奇怪的是,當我使用 VPN 並使用相同的 IP 時,我可以存取伺服器。我能做些什麼?
-telnet 80.***.***.78 80
Trying 80.***.***.78...
telnet: connect to address 80.***.***.78: Connection refused
telnet: Unable to connect to remote host
-route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
-sudo netstat -lapute:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 *:http *:* LISTEN root 6137 2051/apache2
tcp 0 0 *:ssh *:* LISTEN root 6367 2249/sshd
tcp 0 0 pi.local:ssh nmb.local:65535 ESTABLISHED root 8669 2565/sshd: pi [priv
udp 0 0 *:9949 *:* root 5918 1809/dhclient
udp 0 0 *:mdns *:* avahi 6293 2184/avahi-daemon:
udp 0 0 *:54070 *:* avahi 6295 2184/avahi-daemon:
udp 0 0 *:bootpc *:* root 5946 1809/dhclient
udp 0 0 pi.local:ntp *:* root 6310 2200/ntpd
udp 0 0 localhost:ntp *:* root 6309 2200/ntpd
udp 0 0 *:ntp *:* root 6304 2200/ntpd
答案1
這個是正常的。連接埠轉送僅適用於從外向內的連線。這需要一種稱為髮夾的雙重 NAT(路由之前和路由之後的 NAT)形式。
當您設定連接埠轉送時,某些路由器會執行髮夾操作,這會使某些人誤以為連接埠轉送會執行此操作。但事實並非如此。
我更詳細地解釋了它這裡。