netstat command

1. netstat options
-a or --all: Display all sockets in the connection;
-A<network type> or --<network type>: List the relevant addresses in the connection of this network type;
-c or --continuous: continuously list network status;
-C or --cache: Display the cache information of router configuration;
-e or --extend: Display other network related information;
-F or --fib: show FIB;
-g or --groups : Display the list of members of the multicast function group;
-h or --help : online help;
-i or --interfaces: display the web interface information form;
-l or --listening: Display the Socket of the server being monitored;
-M or --masquerade: Display masquerade 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 for network hardware peripherals;
-o or --timers: show timers;
-p or --programs: Display the program identifier 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.

2. The usage of netstat can be found through netstat --help: as follows


3. List all ports (including listening and non-listening)

netstat -a #List all ports
netstat - at     #List all tcp ports
netstat -au #List all udp ports  

4. List all Sockets in listening state

netstat -l # only display listening ports
netstat -lt #Only list all listening tcp ports
netstat -lu #Only list all listening udp ports
netstat -lx #Only list all listening UNIX ports

5. Display statistics for each protocol

netstat -s displays statistics for all ports
netstat -st displays statistics on TCP ports
netstat - su    displays statistics for UDP ports

6. Display PID and process name in netstat output

netstat -pt
netstat -an
netsat -a --numeric-ports
netsat -a --numeric-hosts
netsat -a --numeric-users

7. Continuously output netstat information

netstat -c    #Output network information every second

8. Display the Address Families that are not supported by the system

netstat --verbose

9. Display core routing information

netstat -r

Use the netstat -rndisplay number format, without querying the hostname.

10. Find out the port the program is running on

View all information with root privileges

netstat -ap | grep  ssh

Find out which process is running on the specified port:

netstat -an | grep ':80'

11. Display a list of network interfaces

netstat -i
source:

Detailed explanation of netstat command




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326322138&siteId=291194637