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
これは正常です。ポート フォワーディングは、外部から内部への接続にのみ機能します。ポート フォワーディングでは、LAN 上のサーバーがルーターのパブリック IP アドレスを使用して同じ LAN 上のマシンに接続することはできません。そのためには、ヘアピニングと呼ばれるデュアル NAT (ルーティング前とルーティング後の両方の NAT) 形式が必要です。
一部のルーターでは、ポート転送を設定するとヘアピン処理が行われるため、ポート転送でヘアピン処理が行われると勘違いする人もいます。しかし、実際にはそうではありません。
詳しく説明しましたここ。