리눅스 netstat
IT 위키
리눅스 netstat이란 현재 연결되어 있는 네트워크를 조회하기 위해 사용하는 명령어를 말한다.
주요 기능[편집 | 원본 편집]
- 소켓의 PID 및 프로그램명과 포트번호를 출력한다.
- 라우팅 테이블의 정보를 출력한다.
- IP주소 기반의 접속한 목록을 출력한다.
- 멀티캐스트 멤버 정보를 출력한다.
- 네트워크 인터페이스 정보를 출력한다.
(참고) 확인할 수 없는 정보 (주요 오답)
- ARP 캐시 정보
- MAC 주소
- IP 패킷이 목적지에 도착하기 위해 방문하는 게이트웨이의 순서 정보
상태값[편집 | 원본 편집]
- LISTEN : 서버로 들어오는 패킷을 위해 소켓을 열고 기다리는 상태
- CLOSE-WAIT : 원격 호스트는 종료된 상태이고 소켓을 종료하기 위해 기다리는 상태
- ESTABLISHED : 3way-handshaking이 완료 후 서버와 클라이언트가 서로 연결된 상태
- SYN_RECEIVED: 서버 시스템이 원격 클라이언트로부터 접속 요구를 받아 클라이언트에게 응답을 하였지만 아직 클라이언트에게 확인 메시지는 받지 않는 상태
사용법[편집 | 원본 편집]
# netstat --help
usage: netstat [-veenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}
netstat [-vnNcaeol] [<Socket> ...]
netstat { [-veenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s } [delay]
-r, --route display routing table
-I, --interfaces=<Iface> display interface table for <Iface>
-i, --interfaces display interface table
-g, --groups display multicast group memberships
-s, --statistics display networking statistics (like SNMP)
-M, --masquerade display masqueraded connections
-v, --verbose be verbose
-n, --numeric don't resolve names
--numeric-hosts don't resolve host names
--numeric-ports don't resolve port names
--numeric-users don't resolve user names
-N, --symbolic resolve hardware names
-e, --extend display other/more information
-p, --programs display PID/Program name for sockets
-c, --continuous continuous listing
-l, --listening display listening server sockets
-a, --all, --listening display all sockets (default: connected)
-o, --timers display timers
-F, --fib display Forwarding Information Base (default)
-C, --cache display routing cache instead of FIB
-T, --notrim stop trimming long addresses
-Z, --context display SELinux security context for sockets
<Iface>: Name of interface to monitor/list.
<Socket>={-t|--tcp} {-u|--udp} {-S|--sctp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom
<AF>=Use '-A <af>' or '--<af>'; default: inet
List of possible address families (which support routing):
inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)
netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)
x25 (CCITT X.25)