下面是个个状态的描述:
- *ESTABLISHED
- The socket has an established connection.
- 套接字有一个已建立的连接。
- *SYN_SENT
- The socket is actively attempting to establish a connection.
- 套接字正在积极地尝试建立连接。
- *SYN_RECV
- A connection request has been received from the network.
- 已从网络接收到连接请求。
- *FIN_WAIT1
- The socket is closed, and the connection is shutting down.
- 套接字关闭,连接关闭。
- *FIN_WAIT2
- Connection is closed, and the socket is waiting for a shutdown from the remote end.
- 连接关闭,而套接字正在等待远程结束的关闭。
- *TIME_WAIT
- The socket is waiting after close to handle packets still in the network.
- 该套接字在接近处理网络中的数据包后等待。
- *CLOSED
- The socket is not being used.
- 套接字没有被使用。
- *CLOSE_WAIT
- The remote end has shut down, waiting for the socket to close.
- 远端关闭,等待套接字关闭。
- *LAST_ACK
- The remote end has shut down, and the socket is closed. Waiting for acknowledgement.
- 远端关闭,套接字关闭。等待确认。
- *LISTEN
- The socket is listening for incoming connections. 套接字是监听传入的连接。
- *CLOSING
- Both sockets are shut down but we still don’t have all our data sent.
- 两个套接字都关闭了,但我们仍然没有所有的数据发送。
- *UNKNOWN
- The state of the socket is unknown.
- 套接字的状态未知。
- useage: netstat 【选项】
- descript:查看linux本机的状况
- param:
- -r——显示当前主机路由表信息
- -a——显示当前所有开放的端口(比默认还要多几个)
- -t——显示tcp传输协议的连接状况,等加于netstat | grep tcp 但-t更快
- -u——显示udp传输协议的连接状况,等价于netstat | grep udp
- -i——显示所有网络接口的统计信息表
- -l——显示正处于监听状态的服务和端口
- -p——显示正在使用端口的服务进程号和服务程序名称
- -c——持续列出网络状态,监控连接情况
- -n——以数字的形式显示IP地址和端口号
- -e——显示以太网的统计信息,此项可以与a组合使用
- example
- $ netstat -atn
- Active Internet connections (servers and established)
- 协议 收 送 本地地址与本地连接的远程主机地址连接状态
- Proto Recv-Q Send-Q Local Address Foreign Address State
- tcp 0 0 0.0.0.0:42081 0.0.0.0:* LISTEN
- tcp 0 1 172.30.0.54:47570 74.125.204.102:443 SYN_SENT
- tcp 0 0 172.30.0.54:32840 165.254.134.121:80 ESTABLISHED
- tcp 0 1 172.30.0.54:47568 74.125.204.102:443 SYN_SENT
- tcp6 0 0 :::56937 :::* LISTEN
-
- State——表示连接状态,
- 常见的状态有listen(表示监听状态,等待接收入站的请求)、
- established(表示本机已经与其他主机建立好连接)、
- time_wait(等待足够的时间以确保远程TCP接收连接中断请求的确认)、
- syn sent(尝试发起连接)、
- syn recv(接受发起的连接)等
-
- # 查看所有连接
- $ netstat -a
- # 查看所有tcp连接
- $ netstat -at
- # 查看所有udp连接
- $ netstat -au
- # 查看所有unixsocket连接
- $ netstat -ax
- # 同时列出进场信息
- $ netstat -ap
- # 查看服务器当前的网络连接情况
- $ netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
- # 所有链接到本机的IP
- $ netstat -nut | awk '$NF=="ESTABLISHED" {print $5}' | cut -d: -f1 | sort -u
- # 查看网络监听
- $ netstat -ntlp
- $ netstat -nulp
- $ netstat -nxlp
- # 将会显示使用该端口的应用程序的进程id
- $ netstat -nap | grep port
- # 将会显示包括TCP和UDP的所有连接
- $ netstat -a or netstat –all
- # 将会显示TCP连接
- $ netstat --tcp or netstat –t
- # 将会显示UDP连接
- $ netstat --udp or netstat –u
- # 将会显示该主机订阅的所有多播网络。
- $ netstat -g
- # 有些服务器上没安装telnet等命名跟没有nmap,此时想看远程端口是否开放?
- $ echo >/dev/tcp/8.8.8.8/53 && echo "open"
- # 用netstat显示所有tcp4监听端口
- $ netstat -lnt4 | awk '{print $4}' | cut -f2 -d: | grep -o '[0-9]*'
route (编辑:西安站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|