Show network status
Display a list of active sockets for each protocol:
netstat [-Aan] [-f address_family]
Display the contents of one of the other network data structures:
netstat [-dgiLmnrsv] [-f address_family]
Continuously display (as per the wait interval) the information regarding packet traffic on the configured network interfaces:
netstat [-dn] [-I interface] [-w wait]
Display statistics about the named protocol:
netstat [-p protocol]
Display statistics about the named protocol located at the virtual address:
netstat [-p protocol] -P pcbaddr
Display per-interface statistics for the specified protocol:
netstat [-p protocol] [-i] [-I interface]
Display per-interface statistics for the specified address family:
netstat [-s] [-f address_family] [-i] [-I interface]
Address family: | address_family value: |
---|---|
AF_INET | inet |
AF_INET6 | inet6 |
AF_LOCAL | local or unix |
AF_ARP | arp |
If used with -f address_family and -s, or with -p protocol, show per-interface statistics on the interface for address_family or protocol, respectively.
If you also specify -a, show multicast addresses currently in use for each Ethernet interface and for each IP interface address. Multicast addresses are shown on separate lines following the interface address with which they're associated.
If used with -f address_family and -s, or with -p protocol, show per-interface statistics on the interface for address_family or protocol, respectively.
The netstat utility displays the contents of various network-related data structures.
The default display for active sockets shows the local and remote addresses, the send and receive queue sizes (in bytes), the protocol, and the internal state of the protocol. If a socket's address specifies a network but no specific host address, address formats are of the form host.port or network.port
When known, the host and network addresses are displayed symbolically according to the databases /etc/hosts and /etc/networks, respectively. If a symbolic name for an address is unknown, or if -n is specified, the address is printed numerically, according to the address family. For more information regarding the Internet "dot format," see the inet_*() functions. Unspecified or wildcard addresses and ports appear as *.
The interface display (-i or -w) provides a table of cumulative statistics regarding errors, collisions, and packets transferred. The network addresses of the interface and the maximum transmission unit (MTU) are also displayed.
The routing table display (-r) indicates the available routes and the status of each. Each route consists of a destination host or network and a gateway to use in forwarding packets. The display includes several fields:
Valid flags: | Constant: | Description; |
---|---|---|
1 | RTF_PROTO2 | Protocol specific routing flag #1 |
2 | RTF_PROTO1 | Protocol specific routing flag #2 |
B | RTF_BLACKHOLE | Discard packets during updates |
C | RTF_CLONING | Generate new routes on use This is used by ARP to create the host-specific routes of the hosts on the Ethernet. See option L. |
D | RTF_DYNAMIC | The route was created dynamically by a redirect |
G | RTF_GATEWAY | The route uses a gateway |
H | RTF_HOST | The destination is a host (otherwise, it's a net) |
L | RTF_LLINFO | The route contains a link-layer address. The host routes that ARP clones from the Ethernet network routes all have the link flag set. |
M | RTF_MODIFIED | The route has been modified by a redirect |
R | RTF_REJECT | Host or net unreachable |
S | RTF_STATIC | The route has been added manually |
U | RTF_UP | The route is up |
X | RTF_XRESOLVE | External daemon translates the protocol to a link address |
When -w is specified, netstat displays a running count of statistics related to network interfaces. This display consists of a column for the primary interface (the first interface found during auto-configuration) and a column summarizing information for all interfaces. Using -I, you can replace the primary interface with another interface. The first line of each screen of information contains a summary since the system was last rebooted. Subsequent lines of output show values accumulated over the preceding interval.
The -A, -a, -d, and -s options require the presence of the /etc/protocols file.
/etc/hosts, /etc/networks, /etc/protocols, /etc/services