Intro

Netcat is a utility for checking open ports. It has more flexibility than using the telnet command and can be used with scripts more easily. This is not a comprehensive tutorial, only a quick reference source. Consult the man pages and/or documentation for indepth explanation of commands.

I generally use NMAPs implementation of netcat which is a rewrite of the original netcat utility which is no longer maintained.

TCP

cmd
nc -v www.google.com  80

# success
Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Connected to 216.58.200.100:80.

UDP

UDP tests will always appear successful. You need to run tcp dump and/or check firewall sessions to confirm UDP ports.

cmd
nc -vu 8.8.8.8 53

# success ... maybe ? Check firewall sessions if dont have access to end host for TCPDUMP
Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Connected to 8.8.8.8:53.

Listen On A Port

It's possible to start a 'listener'. This is great for testing through firewalls.

cmd
# TCP
sudo nc -l 10.1.1.10 80

# UDP
sudo nc -l 10.1.1.10 -u 53