【发布时间】:2015-12-05 19:48:31
【问题描述】:
我有一个:
Rasberry Pi 2
运行
Raspbian Jessie Version:November 2015
我正在使用 Undertow(Java http 服务器)为网站提供服务。这是我用来构建服务器的代码。
Undertow server = Undertow.builder()
.addHttpListener(8890, "localhost")
.setHandler(Handlers.pathTemplate()
.add("/", resource(new PathResourceManager(staticFilePath, 100))
.setDirectoryListingEnabled(false))
.build();
问题:尽管能够 ping 和 SSH 进入 PI,但我无法从本地网络上的另一台计算机上看到网络服务器。
我做了什么(在 Pi2 上):
wget localhost:8890
正确返回 index.html
netstat -lptn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 127.0.0.1:8890 :::* LISTEN 1743/java
我的开发机器 192.168.1.8:8890 上的 Chrome 提供 ERR_CONNECTION_REFUSED
wget 192.168.1.8:8890
连接到 192.168.1.8:8890... 失败:连接被拒绝。
nmap 192.168.1.8
Starting Nmap 6.40 ( http://nmap.org ) at 2015-12-05 14:05 CST
Nmap scan report for 192.168.1.8
Host is up (0.039s latency).
Not shown: 999 closed ports
PORT STATE SERVICE
22/tcp open ssh
Nmap done: 1 IP address (1 host up) scanned in 1.83 seconds
我的理解是没有防火墙,所以我很困惑为什么我无法从我的开发机器上看到服务器。
【问题讨论】:
-
从您的主机尝试 nmap 以发现哪些端口是可见的。
-
您发布的 nmap 扫描无论如何都不会显示它已打开,默认扫描仅扫描 1,000 个端口。你可以看到它说 999 关闭并显示 22 打开。这是因为最常见的服务会在 0-1024 的保留范围内创建套接字。如果您想扫描该特定端口,请尝试 nmap -p 8890
标签: linux raspberry-pi raspbian