Linux shell 的ss

news/2024/11/29 20:30:33/

ss的含义 Socket State

1 查看链接

[admin@v035114 ~]$ ss
State      Recv-Q Send-Q                       Local Address:Port                           Peer Address:Port   
ESTAB      0      0                            10.232.35.114:43583                          10.235.171.2:15888   
ESTAB      0      0                            10.232.35.114:1023                           10.232.16.13:nfs     
ESTAB      0      0                            10.232.35.114:54487                          10.232.36.75:ssh     
ESTAB      0      0                            10.232.35.114:33943                          10.235.171.1:13888   
SYN-SENT   0      1                            10.232.35.114:37613                         10.232.14.220:webcache 
ESTAB      0      0                            10.232.35.114:34337                          10.232.17.73:ssh     
ESTAB      0      0                            10.232.35.114:44849                          10.232.36.86:ssh     
ESTAB      1392   0                            10.232.35.114:59068                         10.20.142.112:ssh     
ESTAB      0      0                            10.232.35.114:38479                          10.232.36.88:ssh     
ESTAB      0      0                            10.232.35.114:60156                          10.232.36.88:ssh     
ESTAB      0      0                            10.232.35.114:51222                          10.232.36.86:ssh     
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.35:ccmad   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:65432   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:50906   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:51239   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:53277   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:50813   

第一列表示状态

第二列和第三列的Send-Q和Recv-Q含义

Send-Q 对方没有收到的数据或者说没有Ack的,还是本地缓冲区。

count of bytes not acknowledged by the remote host.

Recv -Q 数据已经在本地接收缓冲,但是还没有recv()

The count of bytes not copied by the user program connected to this socket.

2 选项-n表示不解析服务名

[admin@v035114 ~]$ ss -n
State      Recv-Q Send-Q                         Local Address:Port                           Peer Address:Port 
ESTAB      0      0                              10.232.35.114:43583                          10.235.171.2:15888 
ESTAB      0      0                              10.232.35.114:33943                          10.235.171.1:13888 
ESTAB      1392   0                              10.232.35.114:59068                         10.20.142.112:22    
ESTAB      0      0                              10.232.35.114:60156                          10.232.36.88:22    
ESTAB      0      0                              10.232.35.114:51222                          10.232.36.86:22    
ESTAB      0      0                       ::ffff:10.232.35.114:22                       ::ffff:10.13.44.35:3114  
ESTAB      0      0                       ::ffff:10.232.35.114:22                       ::ffff:10.13.44.34:50813 

端口22对应ssh

3 ss -l 显示本地打开的所有监听端口

[admin@v035114 ~]$ ss -l
Recv-Q Send-Q                            Local Address:Port                                Peer Address:Port   
0      0                                     127.0.0.1:15777                                          *:*       
0      0                                     127.0.0.1:15778                                          *:*       
0      0                                     127.0.0.1:smux                                           *:*       
0      0                                             *:50410                                          *:*       
0      0                                             *:netbios-ssn                                        *:*       
0      0                                             *:sunrpc                                         *:*       
0      0                                             *:http                                           *:*       
0      0                                             *:43698                                          *:*       
0      0                                             *:socks                                          *:*       
0      0                                             *:microsoft-ds                                        *:*       
0      0                                            :::ssh                                           :::*       

使用-n看看服务使用的端口

[admin@v035114 ~]$ ss -ln
Recv-Q Send-Q                              Local Address:Port                                Peer Address:Port 
0      0                                       127.0.0.1:15777                                          *:*     
0      0                                       127.0.0.1:15778                                          *:*     
0      0                                       127.0.0.1:199                                            *:*     
0      0                                               *:50410                                          *:*     
0      0                                               *:139                                            *:*     
0      0                                               *:111                                            *:*     
0      0                                               *:80                                             *:*     
0      0                                               *:43698                                          *:*     
0      0                                               *:1080                                           *:*     
0      0                                               *:445                                            *:*     
0      0                                              :::22                                            :::*     

22 对应ssh

80 对应http

111 对应sunrpc

139 对应netbios-ssn

4 -s 摘要

[admin@v035114 ~]$ ss -s 
Total: 89 (kernel 114)
TCP:   44 (estab 9, closed 23, orphaned 0, synrecv 0, timewait 22/0), ports 80
Transport Total     IP        IPv6
*         114       -         -        
RAW       0         0         0        
UDP       16        13        3        
TCP       21        17        4        
INET      37        30        7        
FRAG      0         0         0       

orphaned什么意思?

最后的 ports 80 什么意思?

RAW、INET、FRAG什么意思?

IPv6 那一 列有好几行数值不为0 设么意思?

5 -t 显示TCP连接

[admin@v035114 ~]$ ss -t
State      Recv-Q Send-Q                       Local Address:Port                           Peer Address:Port   
ESTAB      0      0                            10.232.35.114:59861                         10.235.144.41:ssh     
ESTAB      0      0                            10.232.35.114:43583                          10.235.171.2:15888   
ESTAB      0      0                            10.232.35.114:33943                          10.235.171.1:13888   
ESTAB      1392   0                            10.232.35.114:59068                         10.20.142.112:ssh     
ESTAB      0      0                            10.232.35.114:60156                          10.232.36.88:ssh     
ESTAB      0      0                            10.232.35.114:51222                          10.232.36.86:ssh     
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.35:ccmad   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:50813   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.50:54354   

6 -u显示UDP连接

[admin@v035114 ~]$ ss -t
State      Recv-Q Send-Q                       Local Address:Port                           Peer Address:Port   
ESTAB      0      0                            10.232.35.114:59861                         10.235.144.41:ssh     
ESTAB      0      0                            10.232.35.114:43583                          10.235.171.2:15888   
ESTAB      0      0                            10.232.35.114:33943                          10.235.171.1:13888   
ESTAB      1392   0                            10.232.35.114:59068                         10.20.142.112:ssh     
ESTAB      0      0                            10.232.35.114:60156                          10.232.36.88:ssh     
ESTAB      0      0                            10.232.35.114:51222                          10.232.36.86:ssh     
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.35:ccmad   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:50813   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.50:54354   

7 -p显示使用socket的pid,第一次使用这个命令就是利用-p选项找java的pid,然后jstack java进程, ss -p | grep "db-ip"

[admin@v035114 ~]$ ss -p
State      Recv-Q Send-Q                       Local Address:Port                           Peer Address:Port   
ESTAB      0      0                            10.232.35.114:59861                         10.235.144.41:ssh      users:(("ssh",20182,3))
ESTAB      0      0                            10.232.35.114:43583                          10.235.171.2:15888   
ESTAB      0      0                            10.232.35.114:33943                          10.235.171.1:13888   
ESTAB      1392   0                            10.232.35.114:59068                         10.20.142.112:ssh      users:(("ssh",19281,3))
SYN-SENT   0      1                            10.232.35.114:46842                         10.232.14.220:webcache 
ESTAB      0      0                            10.232.35.114:60156                          10.232.36.88:ssh      users:(("ssh",10249,3))
ESTAB      0      0                            10.232.35.114:51222                          10.232.36.86:ssh      users:(("ssh",10346,3))
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.35:ccmad   
ESTAB      0      180                   ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:50813   
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.50:54354   

括号里面第3位不知道什么意思?
最后一行的::fffff:是什么意思?

8 -o显示定时器信息

[admin@v035114 ~]$ ss -o
State      Recv-Q Send-Q                       Local Address:Port                           Peer Address:Port   
ESTAB      0      0                            10.232.35.114:59861                         10.235.144.41:ssh      timer:(keepalive,21min,0)
ESTAB      0      0                            10.232.35.114:43583                          10.235.171.2:15888   
ESTAB      0      0                            10.232.35.114:33943                          10.235.171.1:13888    timer:(keepalive,6.248ms,0)
ESTAB      1392   0                            10.232.35.114:59068                         10.20.142.112:ssh      timer:(keepalive,19min,0)
SYN-SENT   0      1                            10.232.35.114:56005                         10.232.14.220:webcache  timer:(on,1.092ms,0)
ESTAB      0      0                            10.232.35.114:60156                          10.232.36.88:ssh      timer:(keepalive,32min,0)
ESTAB      0      0                            10.232.35.114:51222                          10.232.36.86:ssh      timer:(keepalive,30min,0)
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.35:ccmad    timer:(keepalive,11min,0)
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.34:50813    timer:(keepalive,18min,0)
ESTAB      0      0                     ::ffff:10.232.35.114:ssh                      ::ffff:10.13.44.50:54354    timer:(keepalive,21min,0)

看到两个类型的timer,都不知道什么意思?

on

keepalive

9 -i 显示内部TCP信息,只打印后几列

[admin@v035114 ~]$ ss -i
Local Address:Port              Peer Address:Port   
10.232.35.114:59861            10.235.144.41:ssh      rto:0.212 ato:0.04 cwnd:3 ssthresh:100 qack:11
10.232.35.114:43583             10.235.171.2:15888    rto:0.204 ato:0.04 cwnd:3 ssthresh:100
10.232.35.114:33943             10.235.171.1:13888    rto:0.212 ato:0.04 cwnd:3 ssthresh:100
10.232.35.114:59068            10.20.142.112:ssh      rto:0.212 ato:0.04 cwnd:20 ssthresh:100
10.232.35.114:43376            10.232.14.220:webcache 
10.232.35.114:60156             10.232.36.88:ssh      rto:0.204 ato:0.04 ssthresh:100 bidir
10.232.35.114:51222             10.232.36.86:ssh      rto:0.204 ato:0.04 cwnd:3 ssthresh:100
::ffff:10.232.35.114:ssh         ::ffff:10.13.44.35:ccmad    rto:0.256 ato:0.04 cwnd:3 ssthresh:3 qack:14
::ffff:10.232.35.114:ssh         ::ffff:10.13.44.34:50813    rto:0.476 ato:0.04 cwnd:5 ssthresh:100 bidir
::ffff:10.232.35.114:ssh         ::ffff:10.13.44.50:54354    rto:0.316 ato:0.04 cwnd:4 ssthresh:100 qack:1


rto

ato

cwnd

ssthresh 都是什么意思啊?

10  Filter过滤的例子

ss -o state established '( dport = :smtp or sport = :smtp )'   显示所有已建立的SMTP连接
ss -o state established '( dport = :http or sport = :http )'  显示所有已建立的HTTP连接





 

 

 


 


http://www.ppmy.cn/news/798215.html

相关文章

Linux命令-ss

ss命令 ss命令是 Socket Statistics 的缩写,用来统计 socket 连接的相关信息,它跟 netstat 差不多,但有着比 netstat 更强大的统计功能,能够显示更多更详细的连接信息。 常用命令 ss -l #列出当前监听的端口 ss -pl #列出其监听的…

shell ss命令

ss命令用来显示处于活动状态的套接字信息。ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容。但ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信息,而且比netstat更快速更高效。 当服务器的socket连接数量变得非常大时&#…

ss 计算机视觉啥意思(ss什么意思)

ss:SelectiveSearch(SS,选择性搜索)选择搜索算法观点:图像中物体可能存在的区域应该是有某些相似性或者连续性的,因此选择搜索采用子区域合并的方法进行提取边界框bounding box 首先,对输入图像进行分割并产生许多子区域&#xff…

ss 命令 使用说明

ss 比 netstat 好用的socket统计信息,iproute2 包附带的另一个工具,允许你查询 socket 的有关统计信息。 补充说明 ss命令 用来显示处于活动状态的套接字信息。ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容。但ss的优…

ss 命令

接数状态获取:netstat在4W以上连接数下工作性能很差。 先看看ss命令: ss -t -a #统计所有的TCP连接 ss -u -a #统计所有的UDP连接 ss还具有过滤功能,下面列一下常用的功能: ss state ESTABLISHED #列出所有ESTABLISHED状态的连接 …

ss命令使用

一、ip ss指令替代 ifconfig route arp netstat 1、ip 指令入门 ip [ OPTIONS ] OBJECT { COMMAND | help } OBJECT 和 COMMAND可以简写到一个字母 ip help      可以查到OBJECT列表和OPTIONS&#xff0c;简写 ip h ip <OBJECT> help   查看针对该OBJECT的帮…

sssf

sdfdsfsdgdg

搭建自己的 SSR

Study Notes Vue SSR 介绍 SSR 官方文档 什么是服务器端渲染 (SSR)&#xff1f; 官方文档Vue SSR&#xff08;Vue.js Server-Side Rendering&#xff09; 是 Vue.js 官方提供的一个服务端渲染&#xff08;同构应用&#xff09;解决方案使用它可以构建同构应用还是基于原有的…