無法從 Windows 連接到 Linux 連接埠

無法從 Windows 連接到 Linux 連接埠

我正在嘗試在 Linux 上執行 gRPC 服務,同時在 Windows 上執行用戶端。

我似乎無法測試我在 Windows 機器上使用的 Linux 連接埠。兩台機器都在同一個網路中。 Windows 10 和 CentOS 8。

這是 Powershell 給我的:

PS C:\WINDOWS\system32> tnc server_ip -p 55555 -Debug
DEBUG: TCP connect to (server_ip  : 55555) threw exception: Exception 
calling "GetResult" with "0" argument(s): "No connection
could be made because the target machine actively refused it 
server_ip :55555"

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is 
"Y"): y
WARNING: TCP connect to (server_ip  : 55555) failed


ComputerName           : server_ip 
RemoteAddress          : server_ip 
RemotePort             : 55555
InterfaceAlias         : Ethernet
SourceAddress          : client_ip
PingSucceeded          : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded       : False

我對 Linux 不太了解,但這裡有一些我嘗試檢查連接埠是否打開以及使用它的服務是否正在運行的命令,以及我得到的結果:

[user@localhost ~]$ grep -w 55555 /etc/services
test        55555/tcp       # TestService

[user@localhost ~]$ sudo lsof -i -P -n | grep LISTEN
[sudo] password for user: 
GrpcServi 10933         user  166u  IPv4 1090871      0t0  TCP 127.0.0.1:55555 (LISTEN)
GrpcServi 10933         user  167u  IPv6 1090874      0t0  TCP [::1]:55555 (LISTEN)

[user@localhost ~]$ sudo netstat -tulpn | grep LISTEN     
tcp        0      0 127.0.0.1:55555         0.0.0.0:*               LISTEN      10933/./GrpcService 
tcp6       0      0 ::1:55555               :::*                    LISTEN      10933/./GrpcService 

[user@localhost ~]$ sudo netstat -tulpn | grep :55555
tcp        0      0 127.0.0.1:55555         0.0.0.0:*               LISTEN      10933/./GrpcService 
tcp6       0      0 ::1:55555               :::*                    LISTEN      10933/./GrpcService 

[user@localhost ~]$ sudo ss -tulpn | grep LISTEN                                               
tcp   LISTEN   0        128              127.0.0.1:55555          0.0.0.0:*      users: 
(("GrpcService",pid=10933,fd=166))                                                                                   
tcp   LISTEN   0        128                  [::1]:55555             [::]:*      users: 
(("GrpcService",pid=10933,fd=167))                                       

[user@localhost ~]$ sudo ss -tulpn | grep ':55555'
tcp   LISTEN   0        128              127.0.0.1:55555          0.0.0.0:*      users: 
(("GrpcService",pid=10933,fd=166))                                       
tcp   LISTEN   0        128                  [::1]:55555             [::]:*      users: 
(("GrpcService",pid=10933,fd=167))                                       

[user@localhost ~]$ sudo lsof -i -P -n | grep LISTEN
GrpcServi 10933         user  166u  IPv4 1090871      0t0  TCP 127.0.0.1:55555 (LISTEN)
GrpcServi 10933         user  167u  IPv6 1090874      0t0  TCP [::1]:55555 (LISTEN)

[user@localhost ~]$ sudo firewall-cmd --zone=public --list-all
[sudo] password for user: 
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp2s0
  sources: 
  services: cockpit dhcpv6-client ssh
  ports: 3389/tcp 3389/udp 55555/tcp 
  protocols: 
  masquerade: yes
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

我還嘗試在 Windows 和 Linux 上停用防火牆以檢查是否有幫助,但沒有效果。

答案1

127.0.0.1::1是本地環回位址。他們是僅有的可從同一台機器存取。這就是為什麼您的其他機器看不到它們。

您將需要更改啟動伺服器的方式。告訴它綁定到本地網路位址(而不是內部網路位址)。

相關內容