May 28th, 2013

How to test host/port connections using netcat (nc)

Because I have to go look up the flags every single time... I figured I'd just write it up here to make it faster. :)

How to test a TCP/IP connection to a remote host (www.google.com) on a given port (80):
$ nc -v -w 1 -z www.google.com 80
Connection to www.google.com 80 port [tcp/http] succeeded!


How to test a UDP/IP connection to a remote host (173.255.181.79) on a given port (4672):
$ nc -u -v -w 1 -z 173.255.181.79 4672
Connection to 173.255.181.79 4672 port [udp/rfa] succeeded!