ss常用指令
- ss簡介
- ss指令選項
- 執行個體
- 最常用指令
- 比對本地位址和端口号
- 将本地或者遠端端口和一個數比較
- 用TCP狀态過濾Sockets
- 顯示TCP連接配接
- 顯示Sockets摘要
- 找出所有端口為22的連接配接
參考位址 https://www.linuxcool.com/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
[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