On Dubian, I can do the following using netcat (aka nc, ncat):michael@pi1:~ $ nc -zv 10.120.11.1 20 21 22 23 24nc: connect to 10.120.11.1 port 20 (tcp) failed: Connection refusedConnection 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 refusedmichael@pi1:~ $man nc on Dubian shows the following: -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.On Centos7, I didn't originally have nc, so added using sudo yum install nmap-ncat.x86_64.But, the -z flag is not supported.[michael@box1 ~]$ nc -zv 10.255.255.1 22nc: invalid option -- 'z'Ncat: Try `--help' or man(1) ncat for more information, usage options and help. QUITTING.[michael@box1 ~]$
Check if remote port is reachable using Centos
centos;netcat
Yea, I found that out as well that nc didn't support -z. I wonder why they dropped it. You could install an older version of ncat, or just use nmap.Nmapnmap -sT -p <port>