Usage of TCPDUMP

DevOps 2015. 9. 21. 13:28

서버에서 테트웍 트래픽을 모니터링하는 도구인 tcpdump 에대한 옵션과 사용 예제이다. 

tcpdump 는 ssh나 ftp등과 같은 커넥션이 서버로 연결이 어떻게 되고 실제로 어떤 데이터들이 오가는지를 체크하는 유용한 툴이다.


기본 사용법

$ tcpdump [option] [target]

$ tcpdump -i eth0



Examples


1. 특정 네트워크 인터페이스의 모든 패킷 정보를 출력합니다.

$ tcpdump -i eth0


2. 특정 네트워크 인터페이스의 지정된 포트의 패킷 정보를 출력합니다. (다음은 21번(FTP)포트를 조사한다)

$ tcpdump -i eth0 port 21


3. 특정 네트워크 인터페이스의 패킷 정보를 파일로 저장합니다.

$ tcpdump -i eth0 -w tcpdump.txt


4. 특정 네트워크 인터페이스의 80번 포트의 패킷 정보를  파일에 저장합니다. 

$ tcpdump -oi eth0 -w tcpdump.txt port 80


5. 특정 아이피(IP)에 해당하는 정보를 출력합니다.

$ tcpdump host xxx.xxx.xxx.xxx



 대표적인 옵션


  • -i any : Listen on all interfaces just to see if you’re seeing any traffic.
  • -i eth0 : Listen on the eth0 interface.
  • -D : Show the list of available interfaces
  • -n : Don’t resolve hostnames.
  • -nn : Don’t resolve hostnames or port names.
  • -q : Be less verbose (more quiet) with your output.
  • -X : Show the packet’s contents in both hex and ASCII.
  • -XX : Same as -X, but also shows the ethernet header.
  • -v, -vv, -vvv : Increase the amount of packet information you get back.
  • -c : Only get x number of packets and then stop.
  • icmp : Only get ICMP packets.
  • -s : Define the snaplength (size) of the capture in bytes. Use -s0to get everything, unless you are intentionally capturing less.
  • -S : Print absolute sequence numbers.
  • -e : Get the ethernet header as well.
  • -q : Show less protocol information.
  • -E : Decrypt IPSEC traffic by providing an encryption key.




Posted by Steven J.S Min
,