-1

我将我的 linux 设置为接入点,然后运行简单的网络服务器,在端口 3000 上打印“hello world”。

并将其与我的智能手机成功连接。

在linux终端中,http://localhost:3000效果很好。

但在智能手机中,

如果我访问http://172.24.1.105:3000,则无法连接到它。(172.24... 是 ap 的 ip)

chrome的错误信息是

无法访问此站点。172.24.1.105 拒绝连接

我搜索了谷歌(https://serverfault.com/questions/725262/what-c ​​auses-the-connection-refused-message )并且我怀疑 linux 的防火墙。

pi@raspberrypi:~/prj/ap_server $ sudo tcpdump -n icmp
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes

... when I access to port 3000, 

15:07:13.102750 IP 192.168.0.3 > 168.126.63.2: ICMP 192.168.0.3 udp port 42531 unreachable, length 386

日志在上面。所以我无法访问 ap 的网络服务器。

所以我想知道两件事......

1.如何禁用其端口块?

2.在tcpdump的日志中,我居然访问了3000端口,为什么日志打印端口是42531?

加)

即使我打字sudo service iptables stop,问题也没有解决

sudo netstat -ntlp | grep 3000日志:

**tcp6 0 0 :::3000 :::* LISTEN 1999/nodejs**

+我按照本教程进行操作-> https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/

并且有 ipv4 设置。

4

3 回答 3

0

如果您想在手机上运行它,它将在 Live IP(外部)地址上运行

如果它在本地地址(localhost)上工作正常而不是在实时 IP 上,则启用从路由器的路由

并允许该特定端口它将正常工作。

于 2016-11-04T04:44:51.560 回答
0

我发现了这个问题。

我的 dhcp 设置是

interface=wlan0      # Use interface wlan0  
listen-address=172.24.1.1 # Explicitly specify the address to listen on  
bind-interfaces      # Bind to the interface to make sure we aren't sending things elsewhere  
server=8.8.8.8       # Forward DNS requests to Google DNS  
domain-needed        # Don't forward short names  
bogus-priv           # Never forward addresses in the non-routed address spaces.  
dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time  

像上面一样。

我尝试连接172.24.1.105可以在移动设备上连续看到但失败的外部 ip()。但是当我尝试使用时172.24.1.1,就成功了。

我不知道为什么。也许有准确的 IP 地址,而移动设备中的某些东西是暂时的。

于 2016-11-04T08:28:35.003 回答
-3

请参阅Node JS not listen to port 1337 on server 上的类似主题

您的网络服务器没有监听远程地址。

于 2016-11-03T09:36:53.813 回答