为什么我无法 telnet 到具有侦听服务的本地端口?

Ski*_*man 5 firewall port telnet

我怀疑这是一个非常简单的问题,或者是一个非常复杂的问题。

我有一个运行 ubuntu 10.04 的无头服务器,我可以通过 ssh 访问它。我拥有系统的完全 root 访问权限。我正在尝试设置一个 ssh 隧道以允许我通过 vnc 访问系统(但这不是我的问题。

我在端口 5903 上运行 vnc,这是其 netstat 输出:


Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:5903            0.0.0.0:*               LISTEN      7173/Xtightvnc
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      
465/sshd
Run Code Online (Sandbox Code Playgroud)

但是当我尝试从同一系统内远程登录到该端口并登录时,出现无法连接错误


# telnet localhost 5903
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection timed out
Run Code Online (Sandbox Code Playgroud)

我能够远程登录到端口 22(作为验证)


~# telnet localhost 22
Trying ::1...
Connected to localhost.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu7
Run Code Online (Sandbox Code Playgroud)

我尝试使用 ufw 打开任何可能的端口(可能是笨拙的方式)


# ufw status numbered
Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 5903                       ALLOW IN    Anywhere
[ 2] 22                         ALLOW IN    Anywhere
Run Code Online (Sandbox Code Playgroud)

还有什么可能在本地阻止此连接?

谢谢你,

编辑:

iptable -L -n 中对端口 5903 的唯一引用是:


Chain ufw-user-input (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:5903
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:5903
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:22
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:8080
Run Code Online (Sandbox Code Playgroud)

如果有用的话我可以发布整个输出。

hosts.allow 和hosts.deny 都只包含注释。

重新编辑:其他一些问题让我想到了 nmap,所以我通过该实用程序运行了端口扫描:


# nmap -v -sT localhost -p1-65535

Starting Nmap 5.00 ( http://nmap.org ) at 2011-11-09 09:58 PST
NSE: Loaded 0 scripts for scanning.
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Initiating Connect Scan at 09:58
Scanning localhost (127.0.0.1) [65535 ports]
Discovered open port 22/tcp on 127.0.0.1
Connect Scan Timing: About 18.56% done; ETC: 10:01 (0:02:16 remaining)
Connect Scan Timing: About 44.35% done; ETC: 10:00 (0:01:17 remaining)
Completed Connect Scan at 10:00, 112.36s elapsed (65535 total ports)
Host localhost (127.0.0.1) is up (0.00s latency).
Interesting ports on localhost (127.0.0.1):
Not shown: 65533 filtered ports
PORT   STATE  SERVICE
22/tcp open   ssh
80/tcp closed http

Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 112.43 seconds
           Raw packets sent: 0 (0B) | Rcvd: 0 (0B)
Run Code Online (Sandbox Code Playgroud)

我认为这表明 5903 被阻止了。我对此非常了解。问题仍然是什么阻碍了它以及如何修改。

重新重新编辑:

为了检查 Paul Lathrop 的建议答案,我首先使用 ifconfig 验证了我的 IP 地址:


eth0      Link encap:Ethernet  HWaddr 02:16:3e:42:28:8f
          inet addr:10.0.10.3  Bcast:10.0.10.255  Mask:255.255.255.0
Run Code Online (Sandbox Code Playgroud)

然后尝试从该地址远程登录到 5903:


# telnet 10.0.10.3 5903
Trying 10.0.10.3...
telnet: Unable to connect to remote host: Connection timed out
Run Code Online (Sandbox Code Playgroud)

没有运气。

重新重新重新编辑:

好吧,我想我已经将它与 vncserver 隔离了一点,而不是防火墙,该死的。我关闭了 vncserver 并让 netcat 监听端口 5903。然后我的 vnc 客户端就能够建立连接并等待响应。看起来我应该追查 vnc 问题。至少这是进步感谢您的帮助

Ski*_*man 2

好吧,我想我已经将它与 vncserver 隔离了一点,而不是防火墙,该死的。我关闭了 vncserver 并让 netcat 监听端口 5903。然后我的 vnc 客户端就能够建立连接并等待响应。看起来我应该追查 vnc 问题。至少这是进步感谢您的帮助