The netstat Command
Sometimes, knowing which active TCP connections are open and running on a networked host is necessary. The netstat command is a useful network tool for checking and verifying those connections. Verifying TCP connections is essential because unexplained TCP connections are a major security risk. The TCP connection shows that something or someone is connected to the local host.
This netstat command shows detailed information about individual network connections, overall and protocol-specific networking statistics, all listening ports, incoming and outgoing network connections, and much more, all of which could help troubleshoot certain kinds of networking issues.
By default, the netstat command resolves IP addresses to domain names and port numbers to well-known applications. We can use a variety of switches with netstat command.
To apply the netstat command in your computer, open the Command Prompt and execute the netstat command alone to show a comparatively simple list of all active TCP connections. For each one, it will show the local IP address, the foreign IP address, along with their relevant port numbers, as well as the TCP state.
Command Syntax
netstat[-a] [-b] [-e] [-f] [-n] [-o] [-p protocol] [-r] [-s] [-t] [-x] [-y] [time_interval] [/?]
[table id=7 /]
Examples of netstat command
netstat -f
The example of a netstat with -f switch shows all active TCP connections. But I want to see the computers I’m connected to in Fully Qualified Domain Name format [-f] instead of a simple IP address. Here’s an example of what you might see:
![netstat f NetworkUstad netstat command](https://networkustad.com/wp-content/uploads/2019/08/netstat-f-300x182.jpg)
The command displays all active TCP connections at the time of execution. The only protocol (in the Proto column) listed is TCP, if UDP is required then you can use -a switch with n switch (netstat –an) to reduce the execution time.
![netstat an NetworkUstad netstat command](https://networkustad.com/wp-content/uploads/2019/08/netstat-an-258x300.jpg)
The information above is displayed in the result of the command with –an switch including the protocol, the local address and port number, the foreign address and port number, and the connection status. An explanation of the different connection states is given below.
[table id=8 /]