- ss简介
- ss命令选项
- 实例
- 最常用命令
- 匹配本地地址和端口号
- 将本地或者远程端口和一个数比较
- 用TCP状态过滤Sockets
- 显示TCP连接
- 显示Sockets摘要
- 找出所有端口为22的连接
参考地址 https://www.linuxcool.com/ss ss简介 ss命令选项 实例
ss -tunlp|grep 端口号
ss -tunlp|grep 22
# 或
ss -tulp|grep 程序名
ss -tulp|grep ssh
# 查看建立的连接
ss -tunp|grep 端口号
[rhel8 root ~]# ss -tunp|grep 22
tcp ESTAB 0 36 192.168.1.178:22 101.204.28.121:27072 users:(("sshd",pid=10926,fd=5),("sshd",pid=10924,fd=5))
tcp ESTAB 0 0 192.168.1.178:22 101.204.28.121:25041 users:(("sshd",pid=10706,fd=5),("sshd",pid=10692,fd=5))
匹配本地地址和端口号
ss src ADDRESS_PATTERN # ss src 192.168.1.178
将本地或者远程端口和一个数比较
[rhel8 root ~]# ss -s Total: 153 TCP: 2 (estab 1, closed 0, orphaned 0, timewait 0) Transport Total IP IPv6 RAW 0 0 0 UDP 3 2 1 TCP 2 2 0 INET 5 4 1 FRAG 0 0 0
找出所有端口为22的连接
[rhel8 root ~]# ss state all sport = :22 # 或 [rhel8 root ~]# ss state all sport = :ssh Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:* tcp ESTAB 0 36 192.168.1.178:ssh 101.204.28.121:26114



