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.
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 built into both Windows and Linux. It is very old, since the early 1990s it has been available in both Unix and Microsoft's OS (as of version 3.119. Therefore, we will be able to use it in both operating systems. It doesn't have a graphical interface like Yes, we can see it in other similar programs that we can install.
It is very important to have control over Internet connections. It is essential to know what devices are connected, the open ports we have, the router configuration ... All this helps to improve network performance, avoid problems and also maintain security at all times. Sometimes problems can arise and it is important to know how to identify what errors may have caused them. That's where some tools or commands like the one we mentioned in this article come into play.
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. The objective is, as we have indicated, to have greater control and reduce the risk of suffering problems.
Use Netstat
To use Netstat in Windows we must go to the command line. To do this we go to Start, write CMD and run it in administrator mode. Later we simply have to write netstat and hit Enter. An image like the one we can see below will appear.
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 whether the connection is active or closed, which appears in the Status column.
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 time. However, we can get the command to run every X time. For 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… whatever 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. Special mention must be made of security, and today there are many threats on the Internet. The fact of using a tool like this can give us a real image of the connections that exist on a server or any computer. We can identify potential malicious connections that may affect us and take action as soon as possible to prevent hackers from accessing your computers and making the situation worse.
But it will also be very useful to analyze open ports at a certain time and thus avoid problems. It is essential for certain applications and to be able to achieve optimal performance.