Netstat is a program that accesses network and related information in the kernel. It provides reports on TCP connections, TCP and UDP monitoring, and process memory management.
Command: netstat [-a][-e][-n][-o][-p Protocol][-r][-s][Interval][1]
The meaning of the options is as follows:
-a Display all sockets, including those that are listening.
-c redisplays it every 1 second until the user interrupts it.
-i displays information about all network interfaces in the format "netstat -i".
-n Use the network IP address instead of the name to display the network connection status.
-r displays the core routing table, the format is the same as "route -e".
-t displays the connection status of TCP protocol
-u displays the connection status of UDP protocol.
-v shows work in progress.
-p displays the specified protocol information.
-b shows the executable programs involved in creating each connection or listening port.
-e Show Ethernet statistics. This option can be used in conjunction with the -s option.
-f displays the fully qualified domain name (FQDN) of the external address.
-o Displays the owned process ID associated with each connection.
-s shows statistics for each protocol.
-x Show NetworkDirect connections, listeners and share endpoints.
-y displays TCP connection templates for all connections. Cannot be combined with other options.
interval The number of seconds to pause between displays when the selected statistics are redisplayed. Press CTRL+C to stop redisplaying statistics. If omitted, netstat will print the current configuration information once.
Commonly used command examples
1. netstat -a | more (list all ports, including listening and unlistening ones)
2. netstat -at (list all tcp ports)
3. netstat -au (list all udp ports)
4. netstat -l (list all ports in listening state)vc3Ryb25nPjwvcD4KPHA+PHN0cm9uZz48aW1nIHNyYz0="http://www.2cto.com/uploadfile/Collfiles/20141114/2014111409193550.jpg" alt="">
5. netstat -lt (list all tcp ports in listening state)
6. netstat -lu (list all udp ports in listening state)
7. netstat - lx (list all unix ports in listening state).