The TCP/IP Guide - Version 3.0 (Contents) ` 1658 _ © 2001-2005 Charles M. Kozierok. All Rights Reserved.
UNIX netstat
On most UNIX systems the netstat utility is very full-featured, with a typical implementation
including dozens of options that can be used to control what information is displayed. These
options may not all be used simultaneously; rather, they are arranged into option groups,
each of which presents one class of information. Within each group, one option is
mandatory; it identifies the group, and hence, the general kind of information that will be
displayed. Other options are also possible in each group, which are optional and modify the
command to provide better control on exactly what is output. In essence, then, netstat is
really like many related utilities rolled into one.
UNIX netstat Option Groups, Options and Parameters
Table 297 provides a simplified summary of the option groups for a typical UNIX netstat
implementation, in this case FreeBSD.
Table 297: Typical UNIX netstat Option Groups, Options and Parameters (Page 1 of 2)
Option Group, Options and
Parameters
Description
netstat [-AaLSW] [-f <family>]
[-p <protocol>] [-n]
This is the default invocation of netstat, with no mandatory options. It
prompts the utility to display a list of active sockets on the host machine.
The other options shown can be used to control what precisely is output;
for example, “-a” causes server processes also to be shown.
netstat -i
[-abdt] [-f <family>] [-n]
netstat -I <interface>
[-abdt] [-f <family>] [-n]
Tells netstat to provide information about all network interfaces (“-i”) or a
particular network interface (“-I <interface>”). The “-a” option causes
multicast addresses to be shown as well, “-b” displays bytes of data in
and out on the interface, “-d” shows the number of dropped packets, and
“-t” displays the value of watchdog timers.
netstat -w <interval> -d
[-I <interface>]
Displays packet traffic information on all interfaces every “<interval>”
seconds, or just on the specified interface if “-I <interface>” is included. If
“-d” is included, also indicates the number of dropped packets.
netstat -s [-s] [-z] [-f <family>]
[-p <protocol>]
Shows system-wide statistics for each of the protocols on the system
(which may be modified to show information for only a particular address
family or protocol). If the “-s” option is repeated, counters that have a
value of zero are suppressed; the “-z” option resets the statistics after
they are displayed.
netstat -i -s
[-f <family>] [-p <protocol>]
netstat -I <interface> -s
[-f <family>] [-p <protocol>]
Displays statistics as for “netstat -s” just above, but on a per-interface
basis rather than aggregated for the whole system.
netstat -m Outputs memory management routine statistics.
netstat -r [-Aa] [-f <family>]
[-n] [-W]
Displays the contents of the host’s routing tables. The options “-A” and “-
a” provide additional information about the routes.
netstat -rs [-s] Displays routing statistics; “-s” suppresses counters with a zero value.