I am looking to test if specific ports are on a host are open. I am using:
nc -z host 22 nc -z host 80 nc -z host 443 nc -z host 8080
which works, but it would be nice to use a one-liner like:
nc -z host 22 80 443 8080
which doesn't work.
I would like to avoid the port range
nc -z host 22-8080 as noted in the man page, if possible, as there is a large gap in port #s I am looking to check. Also, I don't want to scan every port and be seen as scanning for open ports.
Short of writing a bash loop, what are my options for testing if the ports are open? I have dozens of hosts each with a handful of ports to check.