Flag | Usage |
---|---|
-l | listen mode |
-n | numeric-only IP addresses, no DNS |
-p 1234 | local port number. 1234 can be a single port or a range of ports : lo-hi (inclusive) |
-q n | after EOF on stdin, wait n seconds, then quit |
-s 12.34.56.78 | use 12.34.56.78 as the source address |
-u | UDP mode (default is TCP) |
-v | verbose output (Use this to see error messages) |
-w n | wait n seconds before timeout |
-z | zero-I/O mode : scan for listening processes without sending any data to them |
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibitedwill make this test fail displaying :
No route to host
sourceServers='server1 server2 server3'; destinationList='ip.add.ress.1 ip.add.ress.2 ip.add.ress.3'; portList='80 443'; for server in $sourceServers; do for destination in $destinationList; do for port in $portList; do echo -e "\nTESTING FROM '$server' TO '$destination:$port'"; ssh -q $server "nc -nvw3z $destination $port"; done; done; done
nc localhost 8080 GET www.google.com/ HEAD www.google.com/ HEAD www.google.com/ HTTP/1.0 HEAD www.google.com/ HTTP/1.1 ==> the final 'HTTP/1.x' causes an HTTP 504 (???) telnet localhost 8080 HEAD http://www.google.com/ + + ==> HTTP/1.1 302 Found HEAD http://www.google.com/ HTTP/1.0 + + ==> HTTP/1.1 302 Found HEAD http://www.google.com/ HTTP/1.1 + + ==> HTTP 302 HEAD http://www.google.fr/ HTTP/1.1 + + ==> HTTP 200
nc -vz 10.27.26.68 22 nc: timeout cannot be negative nc -vz -w 3 10.27.26.68 22 nc: timeout cannot be negative nc --version nc: timeout cannot be negative type nc nc is aliased to `nc -vzw5n' which nc /usr/bin/nc /usr/bin/nc -vzw5n 10.27.26.68 22 nc: timeout cannot be negative /usr/bin/nc -vzw5 10.27.26.68 22 without -n nc: connect to 10.27.26.28 port 22 (tcp) timed out: Operation now in progress /usr/bin/nc -vzw5 -n 10.27.26.68 22 with detached -n nc: connect to 10.27.26.28 port 22 (tcp) timed out: Operation now in progress