nc — checking ports and transferring data
cheat sheet · netcat (openbsd/ncat) https://lab.dimsanych.ru/en/wiki/nc/Cheat sheet
-
nc -zvw3 host 22is the port open? (refused vs timed out) -
nc -zvu host 53UDP -
nc -zv host 20-25a range -
nc -l 9000listen (a test server) -
echo data | nc host 9000send -
nc -l 9000 > out.binreceive a file (on the other side — nc host 9000 < file.bin)
Options
| Option | Meaning |
|---|---|
-z |
scan mode: only check, don't send data |
-v |
verbose output (refused / open / timed out) |
-u |
UDP instead of TCP |
-l |
listen (server mode) |
-p N |
the local port |
-w N |
connection timeout, in seconds |
-n |
skip DNS resolution (faster) |
-k |
(with -l) don't close after one client |