NETSTAT(8)

๐Ÿ“ฆ
version 2.10 ยท 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian bookworm, debian trixie, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

๐ŸŽ€ NETSTAT(8) ๐ŸŽ€

Okay bestie, this is the netstat(8) page from the Linux System Administrator's Manual ๐Ÿ“–๐Ÿ’– It's your go-to for poking at the Linux networking subsystem ๐Ÿ”ฅ

โœจ NAME โœจ

netstat โ€” print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships ๐Ÿฆ‹

โœจ SYNOPSIS โœจ

netstat [address_family_options] [--tcp|-t] [--udp|-u] [--udplite|-U]
[--sctp|-S] [--raw|-w] [--l2cap|-2] [--rfcomm|-f] [--listening|-l]
[--all|-a] [--numeric|-n] [--numeric-hosts] [--numeric-ports]
[--numeric-users] [--symbolic|-N] [--extend|-e[--extend|-e]]
[--timers|-o] [--program|-p] [--verbose|-v] [--continuous|-c]
[--wide|-W]

netstat {--route|-r} [address_family_options] [--extend|-e[--extend|-e]]
[--verbose|-v] [--numeric|-n] [--numeric-hosts] [--numeric-ports]
[--numeric-users] [--continuous|-c]

netstat {--interfaces|-i} [--all|-a] [--extend|-e[--extend|-e]]
[--verbose|-v] [--program|-p] [--numeric|-n] [--numeric-hosts]
[--numeric-ports] [--numeric-users] [--continuous|-c]

netstat {--groups|-g} [--numeric|-n] [--numeric-hosts] [--numeric-ports]
[--numeric-users] [--continuous|-c]

netstat {--masquerade|-M} [--extend|-e] [--numeric|-n] [--numeric-hosts]
[--numeric-ports] [--numeric-users] [--continuous|-c]

netstat {--statistics|-s} [--tcp|-t] [--udp|-u] [--udplite|-U]
[--sctp|-S] [--raw|-w]

netstat {--version|-V}

netstat {--help|-h}

address_family_options:

[-4|--inet] [-6|--inet6]
[--protocol={inet,inet6,unix,ipx,ax25,netrom,ddp,bluetooth, ... } ]
[--unix|-x] [--inet|--ip|--tcpip] [--ax25] [--x25] [--rose] [--ash]
[--bluetooth] [--ipx] [--netrom] [--ddp|--appletalk] [--econet|--ec]

โœจ NOTES โœจ

Okay so this program is mostly obsolete ๐Ÿ’€ The replacement for netstat is ss, the replacement for netstat -r is ip route, the replacement for netstat -i is ip -s link, and the replacement for netstat -g is ip maddr ๐Ÿซถ

โœจ DESCRIPTION โœจ

Netstat spills the tea on the Linux networking subsystem ๐Ÿ“ The first argument you give it decides what kind of info you get back โœจ

๐ŸŒธ (none)

By default, netstat shows you a list of open sockets ๐Ÿฆ‹ If you don't name any address families, you'll get the active sockets from every configured address family ๐Ÿ’…

  • --route, -r โ€” shows the kernel routing tables ๐Ÿ—บ๏ธ Check out route(8) for the full scoop. Fun fact: netstat -r and route -e give you the exact same output ๐Ÿ’–
  • --groups, -g โ€” shows multicast group membership info for IPv4 and IPv6 ๐ŸŒˆ
  • --interfaces, -i โ€” shows a table of all your network interfaces ๐Ÿ”ฅ
  • --masquerade, -M โ€” shows a list of masqueraded connections ๐Ÿ™ˆ
  • --statistics, -s โ€” shows summary stats for each protocol ๐Ÿ“Š

โœจ OPTIONS โœจ

  • --verbose, -v โ€” be extra chatty and tell you what's going on ๐Ÿ—ฃ๏ธ It especially prints some useful info about unconfigured address families ๐Ÿงš
  • --wide, -W โ€” don't chop off IP addresses; the output gets as wide as it needs to be ๐Ÿฆ‹ This is optional for now so existing scripts don't break ๐Ÿซถ
  • --numeric, -n โ€” show numerical addresses instead of trying to figure out symbolic host, port, or user names ๐Ÿ”ข
  • --numeric-hosts โ€” shows numerical host addresses, but doesn't change how port or user names get resolved ๐Ÿ’œ
  • --numeric-ports โ€” shows numerical port numbers, but doesn't change how host or user names get resolved ๐ŸŒธ
  • --numeric-users โ€” shows numerical user IDs, but doesn't change how host or port names get resolved ๐Ÿ“
  • --protocol=family, -A โ€” picks which address families (or maybe better called low-level protocols) you want connections shown for โœจ family is a comma (,) separated list of keywords like inet, inet6, unix, ipx, ax25, netrom, econet, ddp, and bluetooth ๐ŸŽ€ It does the same thing as using --inet|-4, --inet6|-6, --unix|-x, --ipx, --ax25, --netrom, --ddp, and --bluetooth ๐Ÿ‘‘ The inet family (Iv4) covers raw, udp, udplite, and tcp protocol sockets ๐Ÿฆ‹ The bluetooth family (Iv4) covers l2cap and rfcomm protocol sockets ๐Ÿซง
  • -c, --continuous โ€” makes netstat print the info you picked every single second, nonstop ๐Ÿ”
  • -e, --extend โ€” shows additional info ๐Ÿ” Use this twice if you want maximum detail ๐Ÿคฏ
  • -o, --timers โ€” includes info about networking timers โฑ๏ธ
  • -p, --program โ€” shows the PID and name of the program each socket belongs to ๐Ÿงš You'll see a hyphen if the socket belongs to the kernel (like a kernel service, or a process that exited while its socket still hasn't finished closing) ๐Ÿ’€
  • -l, --listening โ€” shows only listening sockets ๐Ÿ‘‚ These get left out by default, so this is how you find them ๐Ÿซถ
  • -a, --all โ€” shows both listening and non-listening sockets โœจ When you use it with the --interfaces option, it also shows interfaces that aren't up ๐ŸŒˆ
  • -F โ€” prints routing info from the FIB ๐Ÿ“š This one's the default ๐Ÿ’…
  • -C โ€” prints routing info from the route cache ๐Ÿ—ƒ๏ธ
โš ๏ธ bestie, the original page lists -F and -C as routing info options, so make sure you pick the one you actually need before you go wild on the output ๐Ÿ™ˆ

โœจ FILES โœจ

  • /etc/services โ€” the services translation file ๐Ÿงš
  • /proc โ€” the mount point for the proc filesystem ๐Ÿ’œ It's how you get into the kernel's status info, and it's guarded by these files:
    • /proc/net/dev โ€” device information ๐Ÿ”Œ
    • /proc/net/raw โ€” raw socket information ๐Ÿ“
    • /proc/net/tcp โ€” TCP socket information ๐Ÿฆ‹
    • /proc/net/udp โ€” UDP socket information ๐ŸŒธ
    • /proc/net/udplite โ€” UDPLite socket information โœจ
    • /proc/net/igmp โ€” IGMP multicast information ๐Ÿ“ก
    • /proc/net/unix โ€” Unix domain socket information ๐Ÿš
    • /proc/net/ipx โ€” IPX socket information ๐Ÿ’พ
    • /proc/net/ax25 โ€” AX25 socket information ๐Ÿ“ป
    • /proc/net/appletalk โ€” DDP (appletalk) socket information ๐Ÿ
    • /proc/net/nr โ€” NET/ROM socket information ๐Ÿ›ฐ๏ธ
    • /proc/net/route โ€” IP routing information ๐Ÿ—บ๏ธ
    • /proc/net/ax25_route โ€” AX25 routing information ๐Ÿงญ
    • /proc/net/ipx_route โ€” IPX routing information ๐Ÿ›ฃ๏ธ
    • /proc/net/nr_nodes โ€” the NET/ROM nodelist ๐Ÿ“‹
    • /proc/net/nr_neigh โ€” NET/ROM neighbours ๐Ÿ‘ฏ
    • /proc/net/ip_masquerade โ€” masqueraded connections ๐ŸŽญ
    • /proc/net/snmp โ€” statistics ๐Ÿ“Š
  • /sys/kernel/debug/bluetooth/l2cap โ€” Bluetooth L2CAP information ๐Ÿฉต
  • /sys/kernel/debug/bluetooth/rfcomm โ€” Bluetooth serial connections ๐Ÿซง

โœจ SEE ALSO โœจ

Go check out route(8), ifconfig(8), iptables(8), proc(5), ss(8), and ip(8) ๐Ÿ’… They're the squad that pairs perfectly with this one.

โœจ BUGS โœจ

โš ๏ธ Okay, bestie, real talk: every now and then you might see strange info pop up if a socket changes while you're looking at it ๐Ÿ™ˆ It's super unlikely though, so don't spiral.

โœจ AUTHORS โœจ

The netstat user interface was written by Fred Baumgarten <dc6iq@insu1.etec.uni-karlsruhe.de> ๐Ÿ‘‘ The man page was basically done by Matt Welsh <mdw@tc.cornell.edu> ๐ŸŽ€ Alan Cox <Alan.Cox@linux.org> gave it an update, and then Tuan Hoang <tqhoang@bigfoot.com> updated it again ๐Ÿ’–

The man page and the command in the net-tools package got totally rewritten by Bernd Eckenfels <ecki@linux.de> ๐Ÿ”ฅ And UDPLite options were added by Brian Micek <bmicek@gmail.com> ๐ŸŒˆ


That's a wrap, bestie! ๐Ÿฆ‹ This was net-tools, last updated 2014-10-07, and you're officially a NETSTAT(8) legend now ๐Ÿ‘‘๐Ÿ’…โœจ