Centos

使用 Centos 檢查遠端埠是否可訪問

  • July 29, 2017

在 Dubian 上,我可以使用netcat(aka nc, ncat) 執行以下操作:

michael@pi1:~ $ nc -zv 10.120.11.1 20 21 22 23 24
nc: connect to 10.120.11.1 port 20 (tcp) failed: Connection refused
Connection to 10.120.11.1 21 port [tcp/ftp] succeeded!
Connection to 10.120.11.1 22 port [tcp/ssh] succeeded!
Connection to 10.120.11.1 23 port [tcp/telnet] succeeded!
nc: connect to 10.120.11.1 port 24 (tcp) failed: Connection refused
michael@pi1:~ $

Dubian 上的 man nc 顯示以下內容:

-z      Specifies that nc should just scan for listening daemons, without sending any data to them.  It is an error to use this option in conjunction with the -l option.

在 Centos7 上,我原本沒有 nc,所以使用sudo yum install nmap-ncat.x86_64.

但是,-z不支持該標誌。

[michael@box1 ~]$ nc -zv 10.255.255.1 22
nc: invalid option -- 'z'
Ncat: Try `--help' or man(1) ncat for more information, usage options and help. QUITTING.
[michael@box1 ~]$

是的,我也發現 nc 不支持 -z。我想知道他們為什麼放棄它。您可以安裝舊版本的 ncat,或者只使用 nmap。

地圖 nmap -sT -p <port>

引用自:https://unix.stackexchange.com/questions/382593