与 LAN 计算机的 Socket 连接失败?

发布于 2024-12-01 19:08:18 字数 8525 浏览 0 评论 0原文

PC1和PC2通过交换机连接。

PC1--<-->--SWITCH--<-->--PC2

两者都安装了 Windows 7。
PC1 已打开防火墙。
PC2 的防火墙已关闭。
他们可以共享文件。
他们可以互相远程桌面。

PC2 上的端口 80 上有一个 HttpListener,但无法通过端口 80 从 PC1 连接到 PC2。
可能是什么问题?

PC1 网络信息:

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::5948:69a8:d29e:6bfe%11
   Autoconfiguration IPv4 Address. . : 169.254.107.254
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :

PC2 网络信息:

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::5cd8:ed4e:8848:569%11
   Autoconfiguration IPv4 Address. . : 169.254.5.105
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :

telnet pc2 80,来自 PC1 说:
无法在端口 80 上打开与主机的连接:连接失败。

PC2 上的“netstat -anb”:

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  RpcSs
 [svchost.exe]
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:554            0.0.0.0:0              LISTENING
 [wmpnetwk.exe]
  TCP    0.0.0.0:2869           0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:10243          0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:49152          0.0.0.0:0              LISTENING
 [wininit.exe]
  TCP    0.0.0.0:49153          0.0.0.0:0              LISTENING
  eventlog
 [svchost.exe]
  TCP    0.0.0.0:49154          0.0.0.0:0              LISTENING
  Schedule
 [svchost.exe]
  TCP    0.0.0.0:49155          0.0.0.0:0              LISTENING
 [services.exe]
  TCP    0.0.0.0:49156          0.0.0.0:0              LISTENING
 [lsass.exe]
  TCP    169.254.5.105:139      0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    [::]:80                [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:135               [::]:0                 LISTENING
  RpcSs
 [svchost.exe]
  TCP    [::]:445               [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:554               [::]:0                 LISTENING
 [wmpnetwk.exe]
  TCP    [::]:2869              [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:3587              [::]:0                 LISTENING
  p2pimsvc
 [svchost.exe]
  TCP    [::]:5357              [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:10243             [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:49152             [::]:0                 LISTENING
 [wininit.exe]
  TCP    [::]:49153             [::]:0                 LISTENING
  eventlog
 [svchost.exe]
  TCP    [::]:49154             [::]:0                 LISTENING
  Schedule
 [svchost.exe]
  TCP    [::]:49155             [::]:0                 LISTENING
 [services.exe]
  TCP    [::]:49156             [::]:0                 LISTENING
 [lsass.exe]
  TCP    [fe80::5cd8:ed4e:8848:569%11]:445  [fe80::5948:69a8:d29e:6bfe%11]:49569  ESTABLISHED
 Can not obtain ownership information
  UDP    0.0.0.0:68             *:*                    
  Dhcp
 [svchost.exe]
  UDP    0.0.0.0:123            *:*                    
  W32Time
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                    
  EventSystem
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                    
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                    
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                    
  EventSystem
 [svchost.exe]
  UDP    0.0.0.0:5004           *:*                    
 [wmpnetwk.exe]
  UDP    0.0.0.0:5005           *:*                    
 [wmpnetwk.exe]
  UDP    0.0.0.0:5355           *:*                    
  Dnscache
 [svchost.exe]
  UDP    0.0.0.0:56904          *:*                    
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:56906          *:*                    
  EventSystem
 [svchost.exe]
  UDP    0.0.0.0:65438          *:*                    
  EventSystem
 [svchost.exe]
  UDP    127.0.0.1:1900         *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    127.0.0.1:56903        *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    169.254.5.105:137      *:*                    
 Can not obtain ownership information
  UDP    169.254.5.105:138      *:*                    
 Can not obtain ownership information
  UDP    169.254.5.105:1900     *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    169.254.5.105:56902    *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    [::]:123               *:*                    
  W32Time
 [svchost.exe]
  UDP    [::]:3540              *:*                    
  p2pimsvc
 [svchost.exe]
  UDP    [::]:3702              *:*                    
  FDResPub
 [svchost.exe]
  UDP    [::]:3702              *:*                    
  EventSystem
 [svchost.exe]
  UDP    [::]:3702              *:*                    
  FDResPub
 [svchost.exe]
  UDP    [::]:3702              *:*                    
  EventSystem
 [svchost.exe]
  UDP    [::]:5004              *:*                    
 [wmpnetwk.exe]
  UDP    [::]:5005              *:*                    
 [wmpnetwk.exe]
  UDP    [::]:5355              *:*                    
  Dnscache
 [svchost.exe]
  UDP    [::]:56905             *:*                    
  FDResPub
 [svchost.exe]
  UDP    [::]:56907             *:*                    
  EventSystem
 [svchost.exe]
  UDP    [::]:65439             *:*                    
  EventSystem
 [svchost.exe]
  UDP    [::1]:1900             *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    [::1]:56901            *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    [fe80::5cd8:ed4e:8848:569%11]:546  *:*                    
  Dhcp
 [svchost.exe]
  UDP    [fe80::5cd8:ed4e:8848:569%11]:1900  *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    [fe80::5cd8:ed4e:8848:569%11]:56900  *:*                    
  SSDPSRV
 [svchost.exe]

编辑 1 - 一些 Wireshark 报告 (telnet pc2 80):

62  28.544466   169.254.5.105   169.254.107.254 NBSS    126 Session request, to PC1<20> from PC2<00>
63  28.544538   169.254.107.254 169.254.5.105   NBSS    58  Positive session response
64  28.544761   169.254.5.105   169.254.107.254 SMB 213 Negotiate Protocol Request
65  28.545154   169.254.107.254 169.254.5.105   SMB2    228 NegotiateProtocol Response
66  28.545359   169.254.5.105   169.254.107.254 SMB2    162 NegotiateProtocol Request
67  28.545527   169.254.107.254 169.254.5.105   SMB2    228 NegotiateProtocol Response
68  28.546260   169.254.5.105   169.254.107.254 SMB2    220 SessionSetup Request, NTLMSSP_NEGOTIATE
69  28.546416   169.254.107.254 169.254.5.105   SMB2    339 SessionSetup Response, Error: STATUS_MORE_PROCESSING_REQUIRED, NTLMSSP_CHALLENGE
70  28.546836   169.254.5.105   169.254.107.254 SMB2    294 SessionSetup Request, NTLMSSP_AUTH, User: \, Unknown message type
71  28.547306   169.254.107.254 169.254.5.105   SMB2    159 SessionSetup Response, Unknown message type
72  28.547646   169.254.5.105   169.254.107.254 SMB2    162 TreeConnect Request Tree: \\PC1\IPC$
73  28.547723   169.254.107.254 169.254.5.105   SMB2    138 TreeConnect Response

编辑 2 - Wireshark,遵循 TCP 流:

12  2.197774    fe80::5948:69a8:d29e:6bfe   fe80::5cd8:ed4e:8848:569    TCP 86  50243 > http [SYN] Seq=0 Win=8192 Len=0 MSS=1440 WS=256 SACK_PERM=1
14  5.197056    fe80::5948:69a8:d29e:6bfe   fe80::5cd8:ed4e:8848:569    TCP 86  50243 > http [SYN] Seq=0 Win=8192 Len=0 MSS=1440 WS=256 SACK_PERM=1
19  11.197398   fe80::5948:69a8:d29e:6bfe   fe80::5cd8:ed4e:8848:569    TCP 82  50243 > http [SYN] Seq=0 Win=8192 Len=0 MSS=1440 SACK_PERM=1

对不起大家:防火墙没有完全禁用专用网络,仅适用于公共网络,我再次检查并发现..现在一切正常。谢谢。

PC1 and PC2 are connected with a switch.

PC1--<-->--SWITCH--<-->--PC2

Both have Windows 7 installed.
PC1 has it's firewall on.
PC2 has it's firewall off.
They can share files.
They can remote desktop each other.

There is a HttpListener on PC2 on port 80 but it is not possible to connect from PC1 to PC2 on port 80.
What could be the problem?

PC1 Network Info:

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::5948:69a8:d29e:6bfe%11
   Autoconfiguration IPv4 Address. . : 169.254.107.254
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :

PC2 Network Info:

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::5cd8:ed4e:8848:569%11
   Autoconfiguration IPv4 Address. . : 169.254.5.105
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :

telnet pc2 80, from PC1 says:
Could not open connection to the host, on port 80: Connect failed.

"netstat -anb" on PC2:

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  RpcSs
 [svchost.exe]
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:554            0.0.0.0:0              LISTENING
 [wmpnetwk.exe]
  TCP    0.0.0.0:2869           0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:10243          0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:49152          0.0.0.0:0              LISTENING
 [wininit.exe]
  TCP    0.0.0.0:49153          0.0.0.0:0              LISTENING
  eventlog
 [svchost.exe]
  TCP    0.0.0.0:49154          0.0.0.0:0              LISTENING
  Schedule
 [svchost.exe]
  TCP    0.0.0.0:49155          0.0.0.0:0              LISTENING
 [services.exe]
  TCP    0.0.0.0:49156          0.0.0.0:0              LISTENING
 [lsass.exe]
  TCP    169.254.5.105:139      0.0.0.0:0              LISTENING
 Can not obtain ownership information
  TCP    [::]:80                [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:135               [::]:0                 LISTENING
  RpcSs
 [svchost.exe]
  TCP    [::]:445               [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:554               [::]:0                 LISTENING
 [wmpnetwk.exe]
  TCP    [::]:2869              [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:3587              [::]:0                 LISTENING
  p2pimsvc
 [svchost.exe]
  TCP    [::]:5357              [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:10243             [::]:0                 LISTENING
 Can not obtain ownership information
  TCP    [::]:49152             [::]:0                 LISTENING
 [wininit.exe]
  TCP    [::]:49153             [::]:0                 LISTENING
  eventlog
 [svchost.exe]
  TCP    [::]:49154             [::]:0                 LISTENING
  Schedule
 [svchost.exe]
  TCP    [::]:49155             [::]:0                 LISTENING
 [services.exe]
  TCP    [::]:49156             [::]:0                 LISTENING
 [lsass.exe]
  TCP    [fe80::5cd8:ed4e:8848:569%11]:445  [fe80::5948:69a8:d29e:6bfe%11]:49569  ESTABLISHED
 Can not obtain ownership information
  UDP    0.0.0.0:68             *:*                    
  Dhcp
 [svchost.exe]
  UDP    0.0.0.0:123            *:*                    
  W32Time
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                    
  EventSystem
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                    
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                    
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                    
  EventSystem
 [svchost.exe]
  UDP    0.0.0.0:5004           *:*                    
 [wmpnetwk.exe]
  UDP    0.0.0.0:5005           *:*                    
 [wmpnetwk.exe]
  UDP    0.0.0.0:5355           *:*                    
  Dnscache
 [svchost.exe]
  UDP    0.0.0.0:56904          *:*                    
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:56906          *:*                    
  EventSystem
 [svchost.exe]
  UDP    0.0.0.0:65438          *:*                    
  EventSystem
 [svchost.exe]
  UDP    127.0.0.1:1900         *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    127.0.0.1:56903        *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    169.254.5.105:137      *:*                    
 Can not obtain ownership information
  UDP    169.254.5.105:138      *:*                    
 Can not obtain ownership information
  UDP    169.254.5.105:1900     *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    169.254.5.105:56902    *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    [::]:123               *:*                    
  W32Time
 [svchost.exe]
  UDP    [::]:3540              *:*                    
  p2pimsvc
 [svchost.exe]
  UDP    [::]:3702              *:*                    
  FDResPub
 [svchost.exe]
  UDP    [::]:3702              *:*                    
  EventSystem
 [svchost.exe]
  UDP    [::]:3702              *:*                    
  FDResPub
 [svchost.exe]
  UDP    [::]:3702              *:*                    
  EventSystem
 [svchost.exe]
  UDP    [::]:5004              *:*                    
 [wmpnetwk.exe]
  UDP    [::]:5005              *:*                    
 [wmpnetwk.exe]
  UDP    [::]:5355              *:*                    
  Dnscache
 [svchost.exe]
  UDP    [::]:56905             *:*                    
  FDResPub
 [svchost.exe]
  UDP    [::]:56907             *:*                    
  EventSystem
 [svchost.exe]
  UDP    [::]:65439             *:*                    
  EventSystem
 [svchost.exe]
  UDP    [::1]:1900             *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    [::1]:56901            *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    [fe80::5cd8:ed4e:8848:569%11]:546  *:*                    
  Dhcp
 [svchost.exe]
  UDP    [fe80::5cd8:ed4e:8848:569%11]:1900  *:*                    
  SSDPSRV
 [svchost.exe]
  UDP    [fe80::5cd8:ed4e:8848:569%11]:56900  *:*                    
  SSDPSRV
 [svchost.exe]

EDIT1 - Some Wireshark report (telnet pc2 80):

62  28.544466   169.254.5.105   169.254.107.254 NBSS    126 Session request, to PC1<20> from PC2<00>
63  28.544538   169.254.107.254 169.254.5.105   NBSS    58  Positive session response
64  28.544761   169.254.5.105   169.254.107.254 SMB 213 Negotiate Protocol Request
65  28.545154   169.254.107.254 169.254.5.105   SMB2    228 NegotiateProtocol Response
66  28.545359   169.254.5.105   169.254.107.254 SMB2    162 NegotiateProtocol Request
67  28.545527   169.254.107.254 169.254.5.105   SMB2    228 NegotiateProtocol Response
68  28.546260   169.254.5.105   169.254.107.254 SMB2    220 SessionSetup Request, NTLMSSP_NEGOTIATE
69  28.546416   169.254.107.254 169.254.5.105   SMB2    339 SessionSetup Response, Error: STATUS_MORE_PROCESSING_REQUIRED, NTLMSSP_CHALLENGE
70  28.546836   169.254.5.105   169.254.107.254 SMB2    294 SessionSetup Request, NTLMSSP_AUTH, User: \, Unknown message type
71  28.547306   169.254.107.254 169.254.5.105   SMB2    159 SessionSetup Response, Unknown message type
72  28.547646   169.254.5.105   169.254.107.254 SMB2    162 TreeConnect Request Tree: \\PC1\IPC$
73  28.547723   169.254.107.254 169.254.5.105   SMB2    138 TreeConnect Response

EDIT2 - Wireshark, Follow TCP Stream:

12  2.197774    fe80::5948:69a8:d29e:6bfe   fe80::5cd8:ed4e:8848:569    TCP 86  50243 > http [SYN] Seq=0 Win=8192 Len=0 MSS=1440 WS=256 SACK_PERM=1
14  5.197056    fe80::5948:69a8:d29e:6bfe   fe80::5cd8:ed4e:8848:569    TCP 86  50243 > http [SYN] Seq=0 Win=8192 Len=0 MSS=1440 WS=256 SACK_PERM=1
19  11.197398   fe80::5948:69a8:d29e:6bfe   fe80::5cd8:ed4e:8848:569    TCP 82  50243 > http [SYN] Seq=0 Win=8192 Len=0 MSS=1440 SACK_PERM=1

SORRY GUYS: The firewall was not completely disabled for private network only public network, i checked again and found out.. Now everything works. Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可爱咩 2024-12-08 19:08:19

这是防火墙问题,请尝试将所有防火墙(包括交换机)设置为打开。

如果这解决了它,这就不再是堆栈溢出问题......

This is a firewall problem, try to set every firewall including your switch open.

If that solves it, this is no longer a Stack Overflow problem...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文