1. Detailed explanation of TCP connection status
- LISTEN: Listen for connection requests from remote TCP ports
- SYN-SENT: wait for a matching connection request after sending the connection request
- SYN-RECEIVED: After receiving and sending a connection request, wait for the other party to confirm the connection request
- ESTABLISHED: Represents an open connection
- FIN-WAIT-1: Wait for the remote TCP connection interruption request, or the confirmation of the previous connection interruption request
- FIN-WAIT-2: Waiting for connection interruption request from remote TCP
- CLOSE-WAIT: Waiting for a connection interruption request from a local user
- CLOSING: Waiting for the remote TCP to confirm that the connection is interrupted
- LAST-ACK: Waiting for the confirmation of the original connection interruption request sent to the remote TCP
- TIME-WAIT: Wait for enough time to ensure that the remote TCP receives an acknowledgment of the connection interruption request
- CLOSED: no connection status
2. Command format
netstat(options)
3. Command options
- -a or –all: Display Sockets in all connections;
- -A<network type> or –<network type>: list the relevant addresses in the connection of this network type;
- -c or –continuous: Continuously list the network status;
- -C or –cache: Display the cache information of the router configuration;
- -e or –extend: Display other relevant information of the network;
- -F or –fib: display FIB;
- -g or –groups: Display the list of multicast function group members;
- -h or --help: online help;
- -i or –interfaces: display the network interface information form;
- -l or –listening: Display the Socket of the server being monitored;
- -M or –masquerade: display masquerading network connections;
- -n or –numeric: use the ip address directly without going through the domain name server;
- -N or --netlink or --symbolic: Display symbolic link names of network hardware peripherals;
- -o or --timers: display timers;
- -p or –programs: Display the program identification code and program name that are using Socket;
- -r or –route: Display Routing Table;
- -s or –statistice: display network work information statistics table;
- -t or –tcp: Display the connection status of the TCP transport protocol;
- -u or –udp: Display the connection status of the UDP transport protocol;
- -v or –verbose: display the instruction execution process;
- -V or –version: display version information;
- -w or –raw: Display the connection status of the RAW transmission protocol;
- -x or –unix: The effect of this parameter is the same as specifying the "-A unix" parameter;
- –ip or –inet: The effect of this parameter is the same as specifying the "-A inet" parameter.
4. List all ports (including TCP and UDP)
> netstat -a
4. List all TCP ports
> netstat -at
5. List all UDP ports
> netstat -au
6. List all Sockets in listening state
> netstat -l
7. Only list all listening tcp ports
> netstat -lt
8. Only list all listening udp ports
> netstat -lu
9. Only list all listening UNIX ports
> netstat -lx
10 Display statistics for all ports
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
11. Display TCP port statistics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
12. Display UDP port statistics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
13. Show PID and process name in netstat output
> netstat -pt
14. Do not display host, port and user name (host, port or user) in netstat output
> netstat -an
15. Continue to output netstat information
Output network information every second
> netstat -c
16. Display core routing information
1 2 3 4 5 6 7 |
|
17. Use netstat -rn to display the number format without querying the host name.
1 2 3 4 5 6 7 |
|
18. Find out the port the program is running on
1 2 3 |
|
19. Find out the process running on the specified port
1 2 3 4 5 6 7 8 9 10 |
|
20. Find the process ID through the port
1 2 |
|
21. Display a list of network interfaces
1 2 3 4 5 6 7 |
|
22. Statistical list of various states of TCP
1 2 3 4 |
|
The above is the detailed content of the Linux netstat command. For more information about the Linux netstat command, please pay attention to other related articles of developpaer! I hope you will support developpaer a lot in the future!