Windows 指令檢查遠端伺服器連接埠是否開啟?

Windows 指令檢查遠端伺服器連接埠是否開啟?

我有兩台 Windows 伺服器。一種方法是 telnet ..但這只有在服務正在運行並偵聽連接埠時才有效。但是,有沒有辦法無論服務狀態如何都可以查找連接埠是否開啟? Linux 有一個「nc」指令來實現相同的目的。 Windows 中有類似的東西嗎?

謝謝。

答案1

您可以使用 netstat.exe 查詢開放的連接埠。

網路統計.exe:

C:\Users\user>netstat.exe /?

Displays protocol statistics and current TCP/IP network connections.

NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-x] [-t] [interval]

  -a            Displays all connections and listening ports.

範例 netstat -a:

C:\Users\user>netstat -a

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            10.10.11.20:0           LISTENING
  TCP    0.0.0.0:445            10.10.11.20:0           LISTENING
  TCP    0.0.0.0:1433           10.10.11.20:0           LISTENING
  TCP    0.0.0.0:1801           10.10.11.20:0           LISTENING
  TCP    0.0.0.0:2103           10.10.11.20:0           LISTENING

若要執行遠端 netstat.exe,您可以使用 psexec 工具(可從這裡

例子:

C:\Users\user>psexec \\10.10.21.145 netstat -a

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com







Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            10.10.21.145:0         LISTENING
  TCP    0.0.0.0:445            10.10.21.145:0         LISTENING
  TCP    0.0.0.0:2701           10.10.21.145:0         LISTENING
  TCP    0.0.0.0:3389           10.10.21.145:0         LISTENING

相關內容