Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2760134
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2014-06-20 15:44:15

为什么ss比netstat快:
netstat是遍历/proc下面每个PID目录,ss直接读/proc/net下面的统计信息。所以ss执行的时候消耗资源以及消耗的时间都比netstat少很多
1:显示socket摘要
 参数介绍:
-s, --summary        show socket usage summary
  1. [root@s5 ~]# ss -s
  2. Total: 1081 (kernel 1115)
  3. TCP: 871 (estab 602, closed 256, orphaned 0, synrecv 0, timewait 256/0), ports 489

  4. Transport Total IP IPv6
  5. * 1115 - -
  6. RAW 0 0 0
  7. UDP 2 2 0
  8. TCP 615 612 3
  9. INET 617 614 3
  10. FRAG 0 0 0
2:显示打开的网络端口:
 参数介绍:
 -l, --listening      display listening sockets
  1. [root@s5 ~]# ss -l
  2. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  3. LISTEN 0 1024 127.0.0.1:11211 *:*
  4. LISTEN 0 511 *:http *:*
  5. LISTEN 0 32 *:ftp *:*
  6. LISTEN 0 128 :::ssh :::*
  7. LISTEN 0 128 *:ssh *:*
  8. LISTEN 0 100 ::1:smtp :::*
  9. LISTEN 0 100 127.0.0.1:smtp *:*
  10. LISTEN 0 64 :::42942 :::*
  11. LISTEN 0 1024 127.0.0.1:12001 *:*
  12. LISTEN 0 128 *:10050 *:*
  13. LISTEN 0 64 *:62023 *:*
  14. LISTEN 0 128 127.0.0.1:9000 *:*
  15. LISTEN 0 50 *:3306 *:*
  16. [root@s5 ~]#

3:查看进程使用的socket
-p, --processes      show process using socket
  1. [root@haproxy2 ~]# ss -pl ##显示服务名,不显示相应的端口
  2. Recv-Q Send-Q Local Address:Port Peer Address:Port
  3. 0 128 :::sunrpc :::* users:(("rpcbind",1158,11))
  4. 0 128 *:sunrpc *:* users:(("rpcbind",1158,8))
  5. 0 128 :::ssh :::* users:(("sshd",1268,4))
  6. 0 128 *:ssh *:* users:(("sshd",1268,3))
  7. 0 100 ::1:smtp :::* users:(("master",1344,13))
  8. 0 100 127.0.0.1:smtp *:* users:(("master",1344,12))
  9. [root@haproxy2 ~]# ss -pl | grep 25 
  10. [root@haproxy2 ~]# ss -pln | grep 25 ##将服务器名替换为端口
  11. 0 100 ::1:25 :::* users:(("master",1344,13))
  12. 0 100 127.0.0.1:25 *:* users:(("master",1344,12))
  13. [root@haproxy2 ~]#
5:所有的tcp socket和udp socket
 -n,  --numeric        don't resolve service names
 -t,  --tcp                display only TCP sockets
 -u, --udp               display only UDP sockets
  1. [root@haproxy2 ~]# ss -a -t
  2. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  3. LISTEN 0 128 :::sunrpc :::*
  4. LISTEN 0 128 *:sunrpc *:*
  5. LISTEN 0 128 :::ssh :::*
  6. LISTEN 0 128 *:ssh *:*
  7. LISTEN 0 100 ::1:smtp :::*
  8. LISTEN 0 100 127.0.0.1:smtp *:*
  9. ESTAB 0 48 192.168.2.222:ssh 192.168.2.164:55804
  10. [root@haproxy2 ~]# ss -a -u
  11. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  12. UNCONN 0 0 *:sunrpc *:*
  13. UNCONN 0 0 *:syslog *:*
  14. UNCONN 0 0 *:908 *:*
  15. UNCONN 0 0 :::sunrpc :::*
  16. UNCONN 0 0 :::syslog :::*
  17. UNCONN 0 0 :::908 :::*
  18. [root@haproxy2 ~]#

6:
  1. 显示所有已建立的SMTP连接
  2. # ss -o state established '( dport = :smtp or sport = :smtp )'
  3. 显示所有已建立的HTTP连接
  4. # ss -o state established '( dport = :http or sport = :http )'

7:
8:

9:

10:
阅读(927) | 评论(0) | 转发(0) |
0

上一篇:mail发送附件

下一篇:nginx重定向

给主人留下些什么吧!~~