LISTEN:(Listening for a connection.)侦听来自远方的TCP端口的连接请求
SYN-SENT:(Active; sent SYN. Waiting for a matching connection request after having sent a connection request.)再发送连接请求后等待匹配的连接请求
SYN-RECEIVED:(Sent and received SYN. Waiting for a confirming connection request acknowledgment after having both received and sent connection requests.)再收到和发送一个连接请求后等待对方对连接请求的确认
ESTABLISHED:(Connection established.)代表一个打开的连接
FIN-WAIT-1:(Closed; sent FIN.)等待远程TCP连接中断请求,或先前的连接中断请求的确认
FIN-WAIT-2:(Closed; FIN is acknowledged; awaiting FIN.)从远程TCP等待连接中断请求
CLOSE-WAIT:(Received FIN; waiting to receive CLOSE.)等待从本地用户发来的连接中断请求
CLOSING:(Closed; exchanged FIN; waiting for FIN.)等待远程TCP对连接中断的确认
LAST-ACK:(Received FIN and CLOSE; waiting for FIN ACK.)等待原来的发向远程TCP的连接中断请求的确认
TIME-WAIT:(In 2 MSL (twice the maximum segment length) quiet wait after close. )等待足够的时间以确保远程TCP接收到连接中断请求的确认
CLOSED:(Connection is closed.)没有任何连接状态
Show both listening and non-listening sockets
代码语言:javascript
复制
# netstat -a | more : To show both listening and
non-listening sockets.
List all tcp ports.
代码语言:javascript
复制
# netstat -at : To list all tcp ports.
List all udp ports
代码语言:javascript
复制
# netstat -au : To list all udp ports.
List only listening ports
代码语言:javascript
复制
# netstat -l : To list only the listening ports.
List only listening TCP ports.
代码语言:javascript
复制
# netstat -lt : To list only the listening tcp ports.
List only listening UDP ports.
代码语言:javascript
复制
# netstat -lu : To list only the listening udp ports.
List only the listening UNIX ports
代码语言:javascript
复制
# netstat -lx : To list only the listening UNIX ports
List the statistics for all ports.
代码语言:javascript
复制
# netstat -s : To list the statistics for all ports.
List the statistics for TCP (or) UDP ports.
代码语言:javascript
复制
# netstat -st(TCP) : To list the statistics for TCP ports.
代码语言:javascript
复制
# netstat -su(UDP) : List the statistics for UDP ports.
Display PID and program names in the output.
代码语言:javascript
复制
# netstat -pt : To display the PID and program names.
Print the netstat information continuously.
代码语言:javascript
复制
# netstat -c : To print the netstat information continuously.
The kernel routing information.
代码语言:javascript
复制
# netstat -r : To get the kernel routing information.
The port on which a program is running.
代码语言:javascript
复制
# netstat -ap | grep ssh : To get the port
on which a program is running.
Which process is using a particular port:
代码语言:javascript
复制
# netstat -an | grep ':80' : To get the process
which is using the given port.