- tcpdump -
man tcpdump 를 해보면 수많은 기능이 있다. 그중에서 몇가지 기본적으로
알아두면 좋을 기능 몇가지를 살펴 보자.
먼저 tcpdump 명령어를 사용 했을때 캡쳐되는 패킷의 필드의 의미를 알아 보자.
[ 필드 ]
#tcpdump -c 10 port http
19:37:39.808905 IP 11.11.22.22.55657 > aaa.com.http: S 2010410952:2010410952(0) win 5840 <mss 1380,sackOK,timestamp 6154284 0,nop,wscale 6> |
19:37:39.808905 : 시간 정보
11.11.22.22.55657 : 소스 IP 주소와 포트번호( IP : 11.11.22.22. Port : 55657 )
aaa.com.http : 목적지 IP 주소와 포트번호 ( IP : aaa.com. Port : http )
S : 플래그(Flag)
2010410952:2010410952 : 시퀀스 번호( 시작:끝 )
win 5840 : 윈도우 사이즈
[ 옵션 ]
-c Number : 제시된 수의 패킷을 받은 후 종료한다
-e : 각각의 패킷에 link-level 을 표시해준다. (manual)
이 옵션을 사용하면 mac-address 와 ethertype을 표시하여 준다.
-i device : capture할 interface를 지정한다. 지정하지 않으면 제일 낮은 번호를 가진
인터페이스를 기본으로 지정한다.
-n : 주소를 번역 하지 않는다. 이 옵션을 사용하면 DNS lookup 을 표시 하지 않는다.
-q : 프로토콜의 정보를 축약한다.
-v : 조금더 많은 정보를 출력 한다.
-vv : 많은 정보를 출력 한다.
[ 조건식 ]
조건식에는 하나 또는 그이상의 qualifier 의 조합으로 이루어진 primitive 가 사용된다.
qualifier
type : host, net, port 가 있다.
dir : 전송 방향이며 src, dst, src or dst, src and dst
proto : 프로토콜을 지정하며 ,ether, fddi, tr, wlan, ip, ip6, arp, rarp, decnet,
tcp and udp 이다.
primitive
dst host HOST : destination 지정
src host HOST : source 지정
host HOST : src or dst 중 HOST와 부합 하는 패킷
dst net NET : destination network 정보와 부합 하는 패킷
srt net NET : source network 와 부합하는 패킷
net NET : : src or dst network 와 부합 하는 패킷
dst port PORT : source 의 port와 부합하는 패킷
src port PORT : destination port와 부합하는 패킷
port PORT : src or dst port 와 부합하는 패킷
ip proto PROTOCOL : 지정된 종류의 프로토콜과 부합하는 패킷
* 주의 icmp, tcp, udp 등은 또는 \로 escape 해야 한다.
=> icmp, tcp, udp 등으로 줄여서 써도 된다.
ether proto PROTOCOL : 패킷 이 ethertype의 protocol
* protocol arp, ip, rarp 등은 또는 \로 escape 해야 한다.
=> arp, ip, rarp 등으로 줄여서 써도 된다.
[ 예 1 ]
tcpdump -c 5 net 203.244.145 and ether proto \arp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
21:16:56.107941 arp who-has 192.168.0.150 tell 192.168.0.168
21:16:57.607921 arp who-has 192.168.0.166 tell 192.168.0.168
21:16:59.107926 arp who-has 192.168.0.166 tell 192.168.0.168
21:17:02.839099 arp who-has 192.168.0.124 tell 192.168.0.123
21:17:05.108197 arp who-has 192.168.0.166 tell 192.168.0.168
tcpdump -c 5 src port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
21:32:22.719183 IP aaa.com.http > 192.168.0.22.48675: S 1526891179:1526891179(0) ack 102469237 win 5792 <mss 1460,sackOK,timestamp 439043389 7874925,nop,wscale 2>
21:32:22.768411 IP aaa.com.http > 192.168.0.22.48675: . ack 434 win 1716 <nop,nop,timestamp 439043438 7874936>
21:32:22.768820 IP aaa.com.http > 192.168.0.22.48675: P 1:499(498) ack 434 win 1716 <nop,nop,timestamp 439043438 7874936>
21:32:23.382518 IP aaa.com.http > 192.168.0.22.48676: S 1528740963:1528740963(0) ack 766325951 win 5792 <mss 1460,sackOK,timestamp 439044052 7875091,nop,wscale 2>
21:32:23.433134 IP aaa.com.http > 192.168.0.22.48676: . ack 486 win 1716 <nop,nop,timestamp 439044103 7875101>
[ 예 3 ]
tcpdump -c 5 -q host aaa.com and 192.168.0.22
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
21:36:09.208172 IP aaa.com.ssh > 192.168.0.22.41815: tcp 112
21:36:09.238270 IP 192.168.0.22.41815 > aaa.com.ssh: tcp 0
21:36:09.238339 IP aaa.com.ssh > 192.168.0.22.41815: tcp 224
21:36:09.238678 IP aaa.com.ssh > 192.168.0.22.41815: tcp 112
21:36:09.250531 IP 192.168.0.22.41815 > aaa.com.ssh: tcp 0
5 packets captured
9 packets received by filter
0 packets dropped by kernel
'Linux > Tip&Tech' 카테고리의 다른 글
MySQL 유용한 명령어 모음 #1 - SHOW 2 (0) | 2009.06.17 |
---|---|
MySQL 유용한 명령어 모음 #1 - SHOW (0) | 2009.06.17 |
커널 파라메터 관련 (0) | 2008.12.02 |
whowatch (0) | 2008.10.09 |
Areca 드라이버 올리는 방법 (0) | 2008.10.09 |