Linux 명령어 ss (Socket Statistics)
리눅스에서 네트워크 상태를 확인하기 위해 흔히 사용하는 명령어로는 netstat 를 들수 있는데,
대체 명령어로 ss도 사용할 수 있다.
CentOS 6.x x64 에서 가능하니 참고!
#ss [옵션] [필터]
-a : 모든 포트 확인
-t : TCP 포트 확인
-u : UDP 포트 확인
-l : LISTEN 상태 포트 확인
-p : 프로세스명을 표시
-n : 호스트 / 포트 / 사용자이름을 숫자로 표시
[root@centos7 ~]# ss | head -n 5
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
u_str ESTAB 0 0 * 23740 * 23739
u_str ESTAB 0 0 * 23707 * 23706
u_str ESTAB 0 0 * 87021 * 88383
u_str ESTAB 0 0 * 17056 * 17112
[root@centos7 ~]# ss -lt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 2 *:kerberos-adm *:*
LISTEN 0 128 *:sunrpc *:*
LISTEN 0 5 *:kpasswd *:*
LISTEN 0 10 192.168.1.14:domain *:*
LISTEN 0 10 127.0.0.1:domain *:*
LISTEN 0 5 192.168.122.1:domain *:*
LISTEN 0 128 *:ssh *:*
[root@centos7 ~]# ss -pl
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 :::http :::*
[root@centos7 ~]# ss
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp ESTAB 0 64 192.168.1.14:ssh 192.168.1.191:57091
[root@centos7 ~]# ss -n
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp ESTAB 0 0 192.168.1.14:22 192.168.1.191:57091
[root@centos7 ~]# ss -r
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp ESTAB 0 64 centos7.example.com:ssh 192.168.1.191:57091
[root@centos7 ~]# ss -l4
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 127.0.0.1:323 *:*
udp UNCONN 0 0 192.168.122.1:domain *:*
udp UNCONN 0 0 *%virbr0:bootps *:*
udp UNCONN 0 0 *:bootpc *:*
tcp LISTEN 0 128 *:sunrpc *:*
tcp LISTEN 0 5 192.168.122.1:domain *:*
tcp LISTEN 0 128 *:ssh *:*
tcp LISTEN 0 128 127.0.0.1:ipp *:*
tcp LISTEN 0 100 127.0.0.1:smtp *:*
[root@centos7 ~]# ss -lt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:sunrpc *:*
LISTEN 0 5 192.168.122.1:domain *:*
LISTEN 0 128 *:ssh *:*
LISTEN 0 128 127.0.0.1:ipp *:*
LISTEN 0 100 127.0.0.1:smtp *:*
LISTEN 0 128 :::sunrpc :::*
LISTEN 0 128 :::http :::*
LISTEN 0 128 :::ssh :::*
LISTEN 0 128 ::1:ipp :::*
LISTEN 0 100 ::1:smtp :::*