Master Netcat (nc): The Swiss‑Army Knife for Network Scanning and Communication
Netcat (nc) is a compact, versatile network utility often called the Swiss‑army knife of networking, and this guide explains its syntax, option meanings, and provides practical examples for port scanning and connection testing using both TCP and UDP protocols.
nc: The Swiss‑Army Knife of Network Tools
Feature Overview
nc is short for netcat and is renowned as the Swiss‑army knife of networking. Its small size and practical functions make it a simple, reliable tool for various network tasks.
Command Syntax
nc [options] [hostname] [port]Option Meanings
-g : Set up to 8 router hop gateways.
-G : Set source routing pointer (multiple of 4).
-h : Show online help.
-i : Set interval for sending data or scanning ports.
-l : Listen mode to accept incoming data.
-n : Use numeric IP addresses only, bypass DNS.
-o : Specify a file to dump transmitted data in hexadecimal.
-p : Set the local port to use.
-r : Randomly choose source or destination port.
-s : Set the source IP address for outgoing packets.
-u : Use UDP protocol.
-v : Verbose output showing command execution details.
-w : Set timeout for connections.
-z : Zero‑I/O mode, useful for port scanning only.
Reference Examples
Example 1 – Port Scanning
// Scan TCP ports 1‑1000 on 192.168.154.132
# nc -v -z -w2 192.168.154.132 1-1000
// Scan UDP ports 1‑100 on 192.168.154.132
# nc -u -v -z -w2 192.168.154.132 1-100Example 2 – Scan Specific Port
# nc -vz -w2 192.168.154.132 22
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.154.132:22.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
