We earn commission when you buy through affiliate links.
This does not influence our reviews or recommendations.Learn more.
netstat is a command-line online grid tool that is a handytroubleshooting command.
Its cross-platform utility means it’s possible for you to use it onLinux, macOS, or Windows.
netstat can be very handy in the following.
throw in the above command and hit enter.
You will see all the active connections from different states as shown below.
You will see a header withProto, Local Address, Foreign Address, and State.
Lets see brief info about them.
We can filter the connections in different ways.
Show only established connection
We have seen the state in the connection information.
you could use below syntax to view all established connections from/to your Windows server.
Note:to view LISTEN, CLOSE_WAIT, TIME_WAIT you could just use as follows.
To see the connections that are inLISTENINGstate changeESTABLISHEDkeyword in the previous command toLISTENING.
You will get the information about connections that are in the listening state as follows.
Similarly, launch the following command to see all the connections that are inCLOSE_WAITstate.
Finally, use theTIME_WAITflag to get information about all the connections that are inTIME_WAITstate.
Show PID used by port number
Every connection is a process internally.
And every process has an ID, and its calledPID.
We can see the PID of every socket connection using the following command.
The above command displays all the connections with PID.
Lets fire off the command and see how we get the result.
We got an extra column calledPID.
And its theprocess identifier.
A very handy when you have to find out which PID is using the particular port number.
you’re free to see the following info if you use the above command.
It will list out statistics from IPv4, IPv6, ICMPv4, ICMPv6, TCP, UDP, etc.
You will see the statistics of all protocols as shown below.
To find out any errors quickly you’ve got the option to use syntax.
The above command filters all the errors from statistics of all protocols.
Show routing information
To display Route Table, you could use the below syntax.
The following syntax will also list all interfaces.
If you use the above command, then you see the info about routing as shown below.
This will display Received & Sent details.
If you fire off the above command, then you will see a similar result as follows.
Note:you’re free to combinefindstrsyntax to show precise results like below.
The above command will filter the connections and displays only established connections.
Lets see an example.
We can filter the connections using the domain with the following command.
Specify the domain in the command and you will see the filtered connections as follows.
I hope this helps you get familiar with netstat command usage on Windows.
If you are interested in learning Windows administration then I would suggest checking out thiscourse.