【问题标题】:Linux port blocked - This site can't be reached, refused to connectLinux 端口被阻止 - 无法访问此站点,拒绝连接
【发布时间】:2017-03-16 15:32:17
【问题描述】:

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

并成功连接到我的智能手机。

在 linux 终端中,http://localhost:3000 运行良好。

但在智能手机中,

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

chrome的错误信息是

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

我搜索了 Google (https://serverfault.com/questions/725262/what-causes-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 设置。

【问题讨论】:

  • 这是一个很好的例子,说明了为什么您不应该重写错误消息。 “无法到达”和“连接被拒绝”之间存在天壤之别。
  • @EJP 你是什么意思..?无法连接,连接被拒绝...我只是从 chrome 消息中获取的
  • 我说的是 Chrome 消息。如果无法访问该站点,则它不可能拒绝连接。一种或另一种发生了。不是都。 Chrome 不应该重写错误消息。它刚刚引起了混乱。

标签: linux networking port tcp-ip access-point


【解决方案1】:

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

如果它在本地地址 (localhost) 上运行良好,而不是在实时 IP 上运行,那么 从您的路由器启用路由

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

【讨论】:

  • 在移动端,localhost 和外部 ip 都连接被拒绝。
  • 但是现在问题解决了。我的移动设备上的外部 IP 是 172.24.1.105 所以我尝试用这个 ip 连接但失败了,我尝试连接 172.24.1.1 现在连接成功。
  • 我将我的 dns、dhcp 设置为 interface=wlan0, listen-address=172.24.1.1, dhcp-range=172.24.1.50,172.24.1.150,12h 像这样。我混淆了监听地址和外部 IP。你知道有什么不同吗?谢谢...
【解决方案2】:

我发现了问题。

我的 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  

如上。

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

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

【讨论】:

    【解决方案3】:

    Node JS not listening to port 1337 on server查看类似主题

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

    【讨论】:

    • 不是类似的主题。完全不同的信息、原因和治疗方法。
    猜你喜欢
    • 2017-04-04
    • 2021-08-18
    • 2019-04-22
    • 2019-11-30
    • 2021-04-21
    • 2019-09-06
    • 2017-10-05
    • 2021-04-25
    • 2018-06-11
    相关资源
    最近更新 更多