How to Use the Netstat Command and Troubleshoot Windows

Sometimes problems appear that affect our network connections. These failures can be simply due to a bad configuration, a driver not updated, a device that works badly or a problem at the system level. We can make use of different tools and methods to check that everything works correctly. In this article we are going to focus on showing you how to use Netstat to troubleshoot network problems.

What is Netstat

Netstat is a tool that we can use through the command line. It allows us to monitor the networks and also to be able to solve certain problems that may arise. It offers us detailed information about the connections of our device through the terminal.

Netstat Command

Its name comes from Network and Statistics, so it is basically going to show us network statistics. We can also obtain data related to open ports and addresses, for example.

This tool is integrated into both Windows and Linux. Therefore we will be able to use it in both operating systems. It does not have a graphical interface as if we can see in other similar programs that we can install.

How to use and troubleshoot network problems with Netstat

In addition to simply obtaining statistical data on network use and having information that may be interesting to users, we will also be able to solve certain network problems that may arise. After all, Netstat shows us an image of different aspects related to the connection.

Use Netstat

To use Netstat in Windows we must go to the command line. For this we go to Start, write CMD and run it in administrator mode. Later we simply have to write netstat and hit Enter.

Usar Netstat en Windows

There it will show us all the active connections on this device. The first column, Proto, shows us the protocol (TCP or UDP). The second column informs us of the IP addresses and ports of the network interfaces of that equipment for each of the connections. We can also see the IP addresses and ports of the remote devices. Another question that we can see thanks to Netstat is if the connection is active or closed.

The process of loading all connections may take a few minutes, depending on how many there are. However, it is not something that requires a lot of time.

We can see the port numbers of the connections instead of the port names. For this we have to do is run the command netstat -n . We will see that the same information appears as before, but this time the port numbers of the remote connections.

What we have done is static. That is, it is an image at a given moment. However we can get the command to run every X time. To do this we simply have to execute the command netstat -n S, where S = number of seconds to update. For example we can put it to update every 7 seconds, so it would be netstat -n 7.

Netstat commands

With Netstat we can also solve some problems that may arise with our network connection. There are different parameters that we can take into account. We are going to show which are the most used parameters to find specific details of the network.

  • Netstat –a : allows us to know all the networks that are active or inactive at any given time. In this way we will be able to detect possible problems that affect a network.
  • Netstat –e : in this case we can see statistics about incoming and outgoing network packets on a network card.
  • Netstat –f : Displays the fully qualified domain name of remote addresses.
  • Netstat –n : This command, unlike the previous one, displays port numbers instead of names.
  • Netstat –o : shows the ID of each process on each connection.
  • Netstat –p X: with this command we can filter connections according to the protocol (TCP, UDP, tcpv6 or tcpv4. X = TCP, UDP… the protocol we want. For example, it would be netstat –p TCP.
  • Netstat –q : Query the linked listening and non-listening ports.
  • Netstat –s : Shows group statistics by protocol. Thus we can classify networks according to the available protocols: TCP, UDP, ICMP, IPv4 or IPv6.
  • Netstat –r : this command shows us the routing table of the current network.
  • Netstat –t : Provides information about the connections in the download state.
  • Netstat –x : in this case we can obtain information about all NetworkDirect connections.

In short, these are some commands that we can use with Netstat to obtain information related to our connections. This also allows us to solve some problems.