C.W.K.
Stream
Lesson 06 of 13 · published

netstat & ss

~12 min · netstat, ss, listening-ports, connections

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

뭐가 listening, 뭐가 연결됐나

netstat(과 모던 Linux 대체 ss) 가 네트워크 연결, listening 소켓, 라우팅 테이블 보여줌. 끊임없이 묻는 두 질문 — "포트 X 에 뭐가 listening?" 과 "이 머신이 지금 누구랑 진짜 대화 중?" "port already in use" 든 "connection refused" 진단이든 여기서 시작.

출력 읽기

각 줄이 프로토콜, 로컬 주소:포트, 외부 주소:포트, 상태 보여줌. 로컬 0.0.0.0 = 모든 인터페이스에서 listening. 로컬 127.0.0.1 = loopback 만. Listening 소켓 상태 LISTEN; 수립된 연결 ESTABLISHED.

Code

macOS / BSD·bash
# Show everything (TCP and UDP, listening + established)
netstat -an

# Just listening sockets, numeric only
netstat -an | grep LISTEN

# Routing table (we used this in Track 1)
netstat -rn

# macOS doesn't have -p (process info) on netstat
# Use lsof -i for that — next lesson
Linux ss (모던 대체)·bash
# All TCP+UDP listening sockets, numeric, with PIDs
sudo ss -tulnp
# -t  TCP
# -u  UDP
# -l  listening only
# -n  numeric (no DNS)
# -p  process info (PID/program)

# Established connections
ss -tan | head

# Filter for a specific port
ss -tlnp 'sport = :22'

External links

Exercise

netstat -an | grep LISTEN(macOS) 또는 sudo ss -tulnp(Linux) 돌려. 모든 listening 포트 읽어. 각각 설명 가능? :22 SSH, :5000 잊고 있던 dev server, :631 CUPS 인쇄, :5353 mDNSResponder. 모르는 거 조사 가치 있음.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.