netstat -a

The netstat -a command displays statistics for both TCP and User Datagram Protocol (UDP). Here is an example of the netstat -a command:

C:\WINDOWS\Desktop>netstat -a
Active Connections
  Proto  Local Address          Foreign Address        State
  TCP    laptop:1027            LAPTOP:0               LISTENING
  TCP    laptop:1030            LAPTOP:0               LISTENING
  TCP    laptop:1035            LAPTOP:0               LISTENING
  TCP    laptop:50000           LAPTOP:0               LISTENING
  TCP    laptop:5000            LAPTOP:0               LISTENING
  TCP    laptop:1035   ESTABLISHED
  TCP    laptop:nbsession       LAPTOP:0               LISTENING
  TCP    laptop:1027            localhost:50000        ESTABLISHED
  TCP    laptop:50000           localhost:1027         ESTABLISHED
  UDP    laptop:1900            *:*
  UDP    laptop:nbname          *:*
  UDP    laptop:nbdatagram      *:*
  UDP    laptop:1547            *:*
  UDP    laptop:1038            *:*
  UDP    laptop:1828            *:*
  UDP    laptop:3366            *:*

As you can see, the output includes four columns, which show the protocol, the local address, the foreign address, and the state of the port. The TCP connections show the local and foreign destination addresses and the current state of the connection. UDP, however, is a little different; it does not list a state status because UDP is a connectionless protocol and does not establish connections. The following list briefly explains the information provided by the netstat -a command:

  • Proto The protocol used by the connection.

  • Local Address The IP address of the local computer system and the port number it is using. If the entry in the local address field is an asterisk (*), it indicates that the port has not yet been established.

  • Foreign Address The IP address of a remote computer system and the associated port. When a port has not been established, as with the UDP connections, *:* appears in the column.

  • State The current state of the TCP connection. Possible states include established, listening, closed, and waiting.