netstat 명령어는 네트워크 연결, 라우팅 테이블, 통계 등 네트워크 관련 정보를 보여준다. 다음은 netstat을 사용하는 몇가지 예제이다.
1. 활성화된 인터넷 연결과 도메인 소켓 출력
# netstat –an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 52 192.168.20.94:22 192.168.20.150:4332 ESTABLISHED
tcp6 0 0 :::22 :::* LISTEN
udp 0 0 0.0.0.0:68 0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 4 [ ] DGRAM 3384 /dev/log
unix 2 [ ACC ] STREAM LISTENING 2503 @/com/ubuntu/upstart
unix 2 [ ] DGRAM 2610 @/org/kernel/udev/udevd
unix 3 [ ] STREAM CONNECTED 4015
unix 3 [ ] STREAM CONNECTED 4014
unix 2 [ ] DGRAM 3932
unix 2 [ ] DGRAM 3449
unix 3 [ ] DGRAM 2647
unix 3 [ ] DGRAM 2646
unix 3 [ ] STREAM CONNECTED 2595 @/com/ubuntu/upstart
unix 3 [ ] STREAM CONNECTED 2594
2. 프로세스 ID와 프로그램 이름과 함께 활성화된 연결 출력
(어떤 프로그램이 특정 네트워크 연결을 맺었는지 확인하는데 도움)
# netstat -tap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 *:ssh *:* LISTEN 725/sshd
tcp 0 52 192.168.20.94:ssh 192.168.20.150:4332 ESTABLISHED 920/sshd: yklee [pr
tcp6 0 0 [::]:ssh [::]:* LISTEN 725/sshd
3. 라우팅 테이블 출력
# netstat –-route
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.20.0 * 255.255.255.0 U 0 0 0 eth1
default 192.168.20.254 0.0.0.0 UG 0 0 0 eth1
4. RAW 네트워크 통계 출력
# netstat --statistics --raw
Ip:
918 total packets received
20 with invalid addresses
0 forwarded
0 incoming packets discarded
898 incoming packets delivered
258 requests sent out
Icmp:
0 ICMP messages received
0 input ICMP message failed.
ICMP input histogram:
0 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
UdpLite:
IpExt:
InBcastPkts: 577
InOctets: 100925
OutOctets: 35328
InBcastOctets: 70093
[netstat 활용하기]
TCP 커넥션 출력
# netstat --tcp --numeric
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 52 192.168.20.94:22 192.168.20.150:4332 ESTABLISHED
특정 포트를 listening 하고 있는 프로그램 출력
# netstat --tcp --listening --programs
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 *:ssh *:* LISTEN 725/sshd
tcp6 0 0 [::]:ssh [::]:* LISTEN 725/sshd
라우팅 캐쉬 출력
# netstat –rnC
Kernel IP routing cache
Source Destination Gateway Flags MSS Window irtt Iface
192.168.20.117 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.127 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.170 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.109 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.94 203.248.252.2 192.168.20.254 1500 0 0 eth1
192.168.20.154 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.164 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.147 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
203.248.252.2 192.168.20.94 192.168.20.94 l 0 0 0 lo
192.168.20.101 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.68 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.124 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.123 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.49 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.112 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.129 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.27 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.113 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.94 203.248.252.2 192.168.20.254 1500 0 0 eth1
192.168.20.133 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.82 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.128 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.143 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.75 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.58 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.177 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.59 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.151 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.38 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.65 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.156 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.71 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.181 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.44 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.104 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.63 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.77 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.55 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.29 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.157 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.139 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.52 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.84 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.78 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.150 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.150 192.168.20.94 192.168.20.94 il 0 0 0 lo
192.168.20.32 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.73 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.34 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.22 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.149 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.161 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.74 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
192.168.20.50 192.168.20.255 192.168.20.255 ibl 0 0 0 lo
'개발 > Server Side' 카테고리의 다른 글
Process Priority 변경 - nice, renice (0) | 2010.03.04 |
---|---|
커널 파라미터 변경 - sysctl (0) | 2010.03.04 |
시스템 성능 분석 명령어 - sar, vmstat (0) | 2010.03.04 |
bash 쉘스크립트 디버깅 (0) | 2010.03.04 |
Safe Reboot - Magic SysRq Key (0) | 2010.03.04 |