In: Computer Science
What does the netstat command do? The netstat command has many
options. Please
explain the following commonly used options and briefly explain the
meaning of the output. How
can you know which program (i.e., process) is using a specific
port?
~$ netstat -a
~$ netstat -l
~$ netstat -s
~$ netstat -p
~$ netstat -r
~$ netstat -ie
You can ignore those lines related to UNIX domain sockets.
Solution:
Netstat command:
As name stated, netstat is formed from the two words network and statistics. Basically, it is a command-line network utility that's controlled via commands. Netstat commands deliver basic statistics on all network activities and informs users which ports are open for tasks and on which addresses and ports the corresponding connections (TCP, UDP) are running.
In single line, we can say that "To show detailed network status information the netstat command are used.".
Explanation of given options:
~$ netstat -a : This command results in
listing all the LISTENING Ports of TCP and UDP connections.
~$ netstat -l : This command results in listing
all active listening ports connections.
~$ netstat -s : This command results in
displaying statistics for each protocol like TCP, UDP, ICMP, and IP
protocols. To specify a set of protocols the -s parameter in the
command can be used.
~$ netstat -p : This command results in showing
the statistics for the specified protocol.
~$ netstat -r : This command results in
displaying Kernel IP routing table with netstat and route
command.
~$ netstat -ie : This command results in
showing Kernel interface table, it is similar to ifconfig
command.
How can you know which program (i.e., process) is using a specific port?
We can use the netstat command with the -np flags and a pipe to the find or findstr commands.
Syntax:
netstat -np <protocol> | find "port #"
For example: netstat -np TCP | find "80"
Please give thumbsup, if you like it. Thanks.