Ubuntu 端口已开放但无法本地/远程 telnet

Ubuntu 端口已开放但无法本地/远程 telnet

我尝试查阅大量文档/博客但无法解决我的问题。

我在 vmware 工作站内安装了本地 Ubuntu 22.04,其 IP 地址为192.168.100.108。服务器运行良好。

我已经在此服务器和我的 API 项目上安装了 .net 6。到目前为止一切顺利,我的 api 能够在本地执行,您可以在以下日志中看到。

info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000 info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production info: Microsoft.Hosting.Lifetime[0]
      Content root path: /home/kshahzad/repayment-api/ info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:5000/api/pingrequest application/json - info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://localhost:5000/api/pingrequest application/json - - 200 - application/json;+charset=utf-8 201.3972ms info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:5000/api/pingrequest application/json - info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://localhost:5000/api/pingrequest application/json - - 200 - application/json;+charset=utf-8 4.1817ms info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:5000/api/pingrequest application/json - info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://localhost:5000/api/pingrequest application/json - - 200 - application/json;+charset=utf-8 1.4804ms

如果您看到上述日志,则 API 地址是 http://localhost:5000。当我尝试从主机访问 API 时,无法访问。因此,我尝试在客户 ubuntu 服务器中打开端口,以下是屏幕截图中的 ufw 状态,是 FYR。

kshahzad@netcore:~$ sudo ufw allow from any to 192.168.100.108 port 5000 proto tcp
Rule added
kshahzad@netcore:~$ sudo ufw status numbered
Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 22/tcp                     ALLOW IN    Anywhere                  
[ 2] 5432/tcp                   ALLOW IN    Anywhere                  
[ 3] 27017                      ALLOW IN    Anywhere                  
[ 4] 192.168.100.108 5000/tcp   ALLOW IN    Anywhere                  
[ 5] 22/tcp (v6)                ALLOW IN    Anywhere (v6)             
[ 6] 5432/tcp (v6)              ALLOW IN    Anywhere (v6)             
[ 7] 27017 (v6)                 ALLOW IN    Anywhere (v6)             

打开端口后,当我尝试 telnet 时,无法 telnet。

kshahzad@netcore:~$ telnet 192.168.100.108 5000
Trying 192.168.100.108...
telnet: Unable to connect to remote host: Connection refused

当我从同一台 ubuntu 机器上使用 localhost 进行 telnet 时,我能够成功进行 telnet

kshahzad@netcore:~$ telnet localhost 5000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

顺便说一下,从我的主机 Windows 11 机器上,我能够通过端口 22 远程登录这个 ubuntu 服务器。

有人可以指导我做错了什么或者我该如何解决这个问题。

谢谢

相关内容