ss 命令使用
習慣先查看有那些參數可用
[root@www ~]# ss -h
Usage: ss [ OPTIONS ]
ss [ OPTIONS ] [ FILTER ]
-h, --help this message
-V, --version output version information
-n, --numeric don't resolve service names
-r, --resolve resolve host names
-a, --all display all sockets -l, --listening display listening sockets
-o, --options show timer information
-e, --extended show detailed socket information
-m, --memory show socket memory usage
-p, --processes show process using socket
-i, --info show internal TCP information
-s, --summary show socket usage summary
-4, --ipv4 display only IP version 4 sockets
-6, --ipv6 display only IP version 6 sockets
-0, --packet display PACKET sockets
-t, --tcp display only TCP sockets
-u, --udp display only UDP sockets -d, --dccp display only DCCP sockets
-w, --raw display only RAW sockets
-x, --unix display only Unix domain sockets
-f, --family=FAMILY display sockets of type FAMILY
-A, --query=QUERY
QUERY := {all|inet|tcp|udp|raw|unix|packet|netlink}[,QUERY]
-F, --filter=FILE read filter information from FILE
FILTER := [ state TCP-STATE ] [ EXPRESSION ]
例子1 查看Summary
[root@www ~]# ss -s
Total: 648 (kernel 660)
TCP: 23 (estab 5, closed 9, orphaned 1, synrecv 0, timewait 9/0), ports 0
Transport Total IP IPv6
* 660 - -
RAW 0 0 0
UDP 10 7 3
TCP 14 11 3
INET 24 18 6
FRAG 0 0 0
例子2 查看Listen port
[root@www ~]# ss -l
Recv-Q Send-Q Local Address:Port Peer Address:Port
0 128 192.168.11.200:ssh *:*
0 128 127.0.0.1:ipp *:*
0 128 ::1:ipp :::*
0 10 127.0.0.1:smtp *:*
0 128 *:34494 *:*
0 128 :::55498 :::*
0 128 :::sunrpc :::*
0 128 *:sunrpc *:*
# ss -atn //表示列出(a=all; t=tcp; n=不解析服務名稱 ex:http(80) ,ssh(22)....)