Netstat

This diagnostic command displays protocol statistics and current TCP/IP network connections.

Syntax

netstat [-a] [-ens] [-p protocol] [-r] [interval]

Parameters

-a

Displays all connections; server connections are usually not shown.

-e

Displays Ethernet statistics. This may be combined with the -s option.

-n

Displays addresses and port numbers in numerical form (rather than attempting name look-ups).

-s

Displays per-protocol statistics. By default, statistics are shown for TCP, UDP, ICMP, and IP; the -p option may be used to specify a subset of the default.

-p protocol

Shows connections for the protocol specified by protocol; protocol may be tcp or udp. If used with the -s option to display per-protocol statistics, protocol may be tcp, udp, icmp,or ip.

-r

Displays the contents of the routing table.

interval

Redisplays selected statistics, pausing interval seconds between each display. Press CTRL+C to stop redisplaying statistics. If this parameter is omitted, netstat prints the current configuration information once.

Notes on Netstat

The netstat utility provides statistics on the following network components.

Statistic

Purpose

Foreign Address

The IP address and port number of the remote computer to which the socket is connected. The name corresponding to the IP address is shown instead of the number if the HOSTS file contains an entry for the IP address. In cases where the port is not yet established, the port number is shown as an asterisk (*).

Local Address

The IP address of the local computer, and the port number the connection is using. The name corresponding to the IP address is shown instead of the number if the HOSTS file contains an entry for the IP address. In cases where the port is not yet established, the port number is shown as an asterisk (*).

Proto

The name of the protocol used by the connection.

(state)

Indicates the state of TCP connections only. The possible states are:
CLOSED FIN_WAIT_1 SYN_RECEIVED
CLOSE_WAIT FIN_WAIT_2 SYN_SEND
ESTABLISHED LISTEN TIMED_WAIT
LAST_ACK