memos/linux/network stat.md
2024-08-26 20:55:58 +09:00

59 lines
2.5 KiB
Markdown

# 1. netstat
deprecated
# 2. ss
socket statistics
```shell
ss [options] [filter]
```
## 2.1. basic
listening 소켓을 제외하고 연결중인 모든 소켓 표시
```shell
ss
```
```
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
u_str ESTAB 0 0 @37ef18770354690f/bus/systemd/bus-system 9789 * 10972
u_str ESTAB 0 0 @855d8616477e9c56/bus/systemd-timesyn/bus-api-timesync 9317 * 6091
u_str ESTAB 0 0 @248f58c9224923fa/bus/systemd-resolve/bus-api-resolve 9316 * 6090
icmp6 UNCONN 0 0 *%enp1s0:ipv6-icmp *:*
tcp ESTAB 0 0 192.168.200.10:microsoft-ds 192.168.200.100:49576
tcp ESTAB 0 52 [::ffff:192.168.200.10]:ssh [::ffff:192.168.200.100]:49173
```
## 2.2. all
모든 소켓 표시
```shell
ss -a
```
## 2.3. numeric
서비스 이름 대신 숫자로 표기
```shell
ss
...
[::ffff:192.168.200.10]:ssh
```
```shell
ss -n
...
[::ffff:192.168.200.10]:22
```
## 2.4. process
관리자 권한 필요
```shell
ss -p
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp ESTAB 0 36 [::ffff:192.168.200.10]:ssh [::ffff:192.168.200.100]:49173 users:(("sshd",pid=3277,fd=4),("sshd",pid=3160,fd=4))
```