Flags & Options
Netcat offers a range of flags for controlling connections, data transfer, timeouts, and encryption. Different implementations (OpenBSD netcat, GNU netcat, Ncat) support slightly different flags. Below is a curated reference of the most useful flags with examples.
Connection & Listening Flags
-lListen mode — accept incoming connections (server)
nc -l -p 4444-p <port>Specify local port (for listening or source port)
nc -l -p 4444-s <address>Set source IP address
nc -s 10.0.0.1 10.0.0.2 4444-uUse UDP instead of TCP
nc -u 10.0.0.1 4444Data Transfer Flags
-e <program>Execute program after connection (rare in modern netcat)
nc -l -p 4444 -e /bin/bash-c <command>Execute shell command (ncat only)
ncat -l -p 4444 --exec "whoami"-i <interval>Wait interval between lines of text sent
nc -i 2 10.0.0.1 4444-w <timeout>Timeout for connections and final net read
nc -w 5 10.0.0.1 4444Input/Output Flags
-i <file>Read from file instead of stdin
nc 10.0.0.1 4444 < payload.txt-o <file>Save all output to file
nc 10.0.0.1 4444 > output.txt-q <seconds>Quit after EOF on stdin and delay
echo "test" | nc 10.0.0.1 4444 -q 1-vVerbose — show detailed connection info
nc -v 10.0.0.1 4444-vvEven more verbose
nc -vv 10.0.0.1 4444DNS & Proxy Flags (ncat / netcat-openbsd)
--proxy <host:port>Connect via SOCKS4/5 or HTTP proxy
nc --proxy 10.0.0.1:8080 10.0.0.2 80--proxy-type <type>Proxy type: socks4, socks5, or http
nc --proxy 10.0.0.1:8080 --proxy-type http example.com 80-X <version>Connect via SOCKS version (4 or 5)
nc -X 5 -x 10.0.0.1:1080 target.com 80-x <address:port>Set proxy server (SOCKS)
nc -x 10.0.0.1:1080 target.com 80SSL/TLS Flags (ncat)
--sslEnable SSL/TLS encryption
nc --ssl 10.0.0.1 443--ssl-verifyVerify SSL certificate
nc --ssl --ssl-verify 10.0.0.1 443--ssl-cert <file>Client certificate file
nc --ssl --ssl-cert client.crt 10.0.0.1 443--ssl-key <file>Client private key file
nc --ssl --ssl-key client.key 10.0.0.1 443--ssl-cafile <file>CA certificate bundle
nc --ssl --ssl-cafile ca.crt 10.0.0.1 443Implementation Differences
Different distributions ship different netcat versions with varying flag support:
| Version | Commonly Found On | Key Notes |
|---|---|---|
| OpenBSD netcat | macOS, FreeBSD, Debian/Ubuntu | No -e flag. Use ncat or other tools for shell access. |
| GNU netcat (traditional) | Older Linux distros, Kali | Has -e flag but has known security issues. |
| Ncat (Nmap project) | Kali, Parrot, manual install | Enhanced, supports SSL, proxy, --exec, and --keep-open. |
| netcat-traditional | Ubuntu/Debian (installable via apt) | Classic version with -e. Install explicitly on newer distros. |
Info
nc -h or man nc. Some flags like -e are intentionally omitted from secure implementations.