Basic Usage
Netcat (nc) is a simple yet powerful networking utility that reads and writes data across network connections using TCP or UDP protocols. It's often called the "Swiss Army knife" of networking tools due to its versatility.
Basic Syntax
The basic syntax for Netcat is:
host: Target hostname or IP address
port: Target port number
[options: Various flags to modify behavior
Connection Modes
Netcat operates in two primary modes:
Client Mode (Default)
Connects to a remote host and port. This is the default behavior when you specify a host and port.
Listen Mode (-l)
Listens for incoming connections on a specified port. Use the -l flag to enable listen mode.
Simple Examples
Connect to a Web Server
Establish a TCP connection to a web server on port 80:
After connecting, you can manually type HTTP requests:
Listen for Connections
Listen for incoming TCP connections on port 4444:
UDP Connection
Use UDP instead of TCP with the -u flag: