Netstat (Network Statistics) is a command-line tool for monitoring and troubleshooting computer network issues. This tool shows you all your device’s connections in as much detail as you need.
With Netstat, you can view all your connections and their ports and stats. This information is valuable when setting up or fixing your connectivity. This article will introduce you to the Netstat command and the main parameters for filtering information displayed about your connections.
Using Netstat command to troubleshoot network issues
We’ll explore the following topics in this section:
- How to use the Netstat command.
- Use netstat parameters to filter connection information.
- Combining Netstat parameters.
Join me as we go through the above topics to help you better understand this tool and learn how to use it to troubleshoot your network issues.
1] How to use the netstat command
Click on the Start button and search for Command Prompt. Open Command Prompt with elevated privileges by right-clicking on it and selecting the Run as administrator option.
You can open Netstat by typing the following command and pressing ENTER:
You may not understand what the columns mean if you’re new to networking.
- Proto: The network protocol. It could be either TCP or UDP.
- Local Address: The IP addresses and ports of your computer’s network interfaces for the given connections.
- Foreign Address: The IP addresses and port names of the remote devices.
- State: Indicates the state of the connection. For example, find out active and closed connections.
The netstat command shows you your active connections and their details. However, you’d notice that the foreign address column prints the IP address and port names.
To show the connections’ port numbers instead of the port names next to the IP addresses, use the following command:
Further, the system can disconnect or connect to networks, and the network details can change at intervals. Hence, we can use the following command to refresh the netstat network details at intervals using this command:
netstat -n 5
To stop the refreshing, press the CTRL + C key combination.
NOTE: The 5 in the command above refreshes the command every 5 seconds. If you wish to increase or shorten the interval, you can modify this value.
2] Use netstat parameters to filter connection information
netstat command is a powerful command that can show you every detail about your device’s connections. Explore the most commonly used netstat parameters to find specific network details.
- Display active and inactive connections
Show the networks that are active or inactive.
- Display applications information
List all applications that are associated with the connections.
- View network adapter stats
Show statistics on incoming and outgoing network packets.
- Display foreign addresses’ fully qualified domain name (FQDNS)
If you don’t want to see the port numbers or names, the following netstat parameter will show your foreign addresses’ fully qualified domain names.
- Show port numbers instead of names
Change the foreign address port names to port numbers.
- Display the process ID
netstat, and it has an extra column for every connection’s Process ID (PID).
- Filter connections by protocol
Display the connections for the protocol you specify – UDP, TCP, tcpv6, or udpv6.
netstat -p udp
NOTE: You should change the
udp part to the protocol whose connections you want to view.
- View non-listening and listing port
Show connections and their listening and bound non-listening ports.
- Group stats by protocol
Categorize networks by available protocols – UDP, TCP, ICMP, IPv4, and IPv6.
- Display routing table
Show the routing table of your current network. It lists every route to the destination and matrix available on your system. Similar to the
route print command.
- Display offload state connections
Show a list of connection offload states of your current connection.
- See NetworkDirect connections
Shows all NetworkDirect connections.
- Display connection Templates
Show your networks’ TCP connection templates.
3] Combining Netstat parameters
You can further filter the Netstat parameters to show you information about your connections any way you want. From the above commands, you only have to add a second parameter to show a combined view.
For instance, you can combine the
-e parameters to view the statistics for every protocol. This way, you can combine other parameters to get the desired results.
When mixing multiple Netstat parameters, you don’t need to include two dashes (-). You can use one dash (-) and append the parameter letters without a second one.
For example, instead of typing the following command:
netstat -s -e
You can write it as:
netstat - se
If you forget the parameters, a quick way to remember them is by asking netstat to help. Simply run the following command:
To stop the netstat query process, press the CTRL + C key combination.
Can we check network connectivity using netstat?
We can check network connectivity using the netstat or network statistics command. This allows us to see active network connections and their status. The tool can view incoming and outgoing network connections, routing tables, port listening, and usage statistics. This command can be handy for network administrators when troubleshooting network issues. By understanding how to use this command, you can quickly and efficiently diagnose problems with your network.
How do I see network issues in Windows?
You can check your network connection status in Windows quickly and easily. Select the Start button to do so and type “settings” into the search bar. Once you’re in the Settings menu, select “Network & internet.” The status of your network connection will be displayed at the top of the page. If you’re having trouble connecting to the internet, this is a helpful first step in troubleshooting the issue. You also check quickly, and if you see the wifi icon missing, you have a network issue.