Unix/Linux命令行小技巧(14)- 显示指定网络协议的所有连接

使用“ss -o state established '( dport = :protocol or sport = :protocol )'”命令可以显示所有网络协议为protocol的连接。
举个例子:

[root@localhost nan]# ss -o state established '( dport = :ssh or sport = :ssh )'
Recv-Q Send-Q                        Local Address:Port                            Peer Address:Port
0      0                            192.168.23.150:ssh                            10.228.155.38:49631    timer:(keepalive,87min,0)

把协议换成http

[root@localhost nan]# ss -o state established '( dport = :http or sport = :http )'
Recv-Q Send-Q                        Local Address:Port                            Peer Address:Port

技巧出处:https://twitter.com/nixcraft/status/272857310689366016

 

发表评论

邮箱地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.