GNU Netcat
$ nc Foundation Med RiskGNU Netcat (nc) reads and writes raw data across TCP and UDP connections (nc -vz host 443, nc -l -p 8080). Useful for fast port reachability checks with -z -w, though unencrypted transport and subtle flag differences between GNU Netcat, OpenBSD nc, and Nmap ncat require care.
brew install netcat Performs raw local/LAN TCP/UDP port probing and socket piping (nc -vz); MCP tools cannot open raw network sockets.
Agent-Readiness Checklist
Local Probe EvidenceCaptured --help excerpt
nc: unrecognized option `--help' usage: nc [-46AacCDdEFhklMnOortUuvz] [-K tc] [-b boundif] [-i interval] [-p source_port] [--apple-recv-anyif] [--apple-awdl-unres] [--apple-boundif ifbound] [--apple-no-cellular] [--apple-no-expensive] [--apple-no-flowadv] [--apple-tcp-timeout conntimo] [--apple-tcp-keepalive keepidle] [--apple-tcp-keepintvl keepintvl] [--apple-tcp-keepcnt keepcnt] [--apple-tclass tclass] [--tcp-adp-rtimo num_probes] [--apple-intcoproc-allow] [--apple-tcp-adp-wtimo num_probes] [--setsockopt-later] [--apple-no-connectx] [--apple-delegate-pid pid] [--apple-delegate-uuid uuid] [--apple-kao] [--apple-ext-bk-idle] [--apple-netsvctype svc] [---apple-nowakefromsleep] [--apple-notify-ack] [--apple-sockev] [--apple-tos tos] [--apple-tos-cmsg] [--apple-tcp-maxseg mss] [-s source_ip_address] [-w timeout] [-X proxy_version] [-x proxy_address[:port]] [hostname] [port[s]]
FCRS-1.0 6-Dimension Breakdown
Zero-I/O -z returns clean exit codes with -w timeouts, but stderr text is unstructured and nc flag syntax varies wildly across GNU, BSD, and ncat.
nc -vz -w 2gives reliable boolean port exit status- Flag incompatibility across GNU vs OpenBSD
ncbuilds
Plaintext-only TCP/UDP without TLS; GNU Netcat also supports dangerous -e/-c program execution flags and arbitrary listener binding.
- Unencrypted sockets; supports
-e/-cexecution flags
Pre-installed /usr/bin/nc on macOS/Linux is usually OpenBSD nc rather than GNU Netcat (brew install netcat), causing flag surprises (-p with -l).
- Requires
brew install netcaton macOS if GNU flags are expected
Handy minimal TCP/UDP reachability check, though socat, curl, and websocat handle TLS and structured protocols much better.
- Minimal raw socket probing without TLS
Legacy GNU Netcat upstream (0.7.1) is largely dormant compared to OpenBSD nc or Nmap ncat.
- Dormant upstream SourceForge releases since
0.7.1
Basic nc --help and GNU Netcat man/info pages.
nc --helpand netcat.sourceforge.net docs
Security, Auth & Guardrails
No authentication credentials or TLS certificates supported; all socket traffic is plaintext.
Free, GPL-2.0 open-source GNU utility.
# GNU Netcat (nc) Agent Rules - Always pass `-w <seconds>` so `nc` cannot hang indefinitely on unresponsive hosts. - Never use `-e` / `-c` command execution flags or bind `-l` on public interfaces; check `nc -h` first because macOS/Linux often ship incompatible `nc` variants.
Agent-Ready Command Recipes
Safe Read-Only Queries
nc -vz -w 2 127.0.0.1 8080
Performs a zero-I/O connect check (-z) with a 2-second timeout (-w 2) on 127.0.0.1:8080.
Controlled Writes & Previews
printf 'HEAD / HTTP/1.0\r\nHost: localhost\r\n\r\n' | nc -w 2 127.0.0.1 8080
Sends a raw HTTP HEAD request to 127.0.0.1:8080 and closes after a 2-second idle timeout.
Strengths for Agents
- + Fast, lightweight boolean TCP port check via
nc -vz -w <secs> <host> <port>. - + Simple stdin/stdout piping for quick raw protocol debugging.
Caveats & Pitfalls
- ! Incompatible
-l/-p/-qflags between GNU Netcat, macOS BSDnc, and Linuxnetcat-openbsd. - ! Dormant upstream maintenance and no native TLS encryption.