본문으로 건너뛰기

dnstop 설치 방법과 사용법은 무엇인가요?

💡 요약 정리

  • dnstop은 DNS 질의를 모니터링하기 위한 오픈소스 TUI 프로그램입니다
  • 실시간으로 패킷을 분석하여 DNS 관련 통계를 제공합니다
  • libcap 라이브러리를 먼저 설치한 후 yum으로 dnstop을 설치합니다
  • dnstop -4 -l 3 eth0 명령으로 IPv4 패킷을 모니터링합니다
  • 실행 중 t키로 쿼리 타입 기준, 2키로 도메인 레벨 2까지 카운터를 볼 수 있습니다

dnstop 툴은 DNS 질의를 모니터링하기 위한 오픈소스입니다.

dnstop은 SSH등을 이용하여 서버에 터미널로 접속하여 볼 수 있는 TUI 프로그램이다.

dnstop은 실시간으로 패킷을 분석하여 DNS관련 패킷을 우리가 알아보기 편리하게 통계를 내어 줍니다.

공식 홈페이지 : http://dns.measurement-factory.com/tools/dnstop/

RPM 파일 다운로드 : http://pkgs.repoforge.org/dnstop/


1. libcap 라이브러리 설치

[root@test localhost]# yum -y install libcap libcap-devel

2. dnstop 설치

yum 명령어를 이용하여 dnstop 패키지를 설치합니다.

[root@test localhost]# yum -y install dnstop
Loaded plugins: dellsysid, fastestmirror

Loading mirror speeds from cached hostfile
Excluding mirror: data.nicehosting.co.kr
 * addons: centos.tt.co.kr
Excluding mirror: data.nicehosting.co.kr
 * base: centos.tt.co.kr
 * epel: mirror.premi.st
Excluding mirror: data.nicehosting.co.kr
 * extras: centos.tt.co.kr
Excluding mirror: data.nicehosting.co.kr
 * updates: centos.tt.co.kr
Excluding Packages from CentOS-5 - Base
Finished
Excluding Packages from CentOS-5 - Updates
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package dnstop.x86_64 0:20121017-3.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================
 Package                                       Arch                                          Version
=====================================================================================================
Installing:
 dnstop                                        x86_64                                        20121017-3.el5

Transaction Summary
=====================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 30 k
Downloading Packages:
dnstop-20121017-3.el5.x86_64.rpm
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : dnstop                                                   1/1

Installed:
  dnstop.x86_64 0:20121017-3.el5

Complete!

3. 사용법

[root@test ~]# dnstop
usage: dnstop [opts] netdevice|savefile
        -4      Count IPv4 packets
        -6      Count IPv6 packets
        -a      Anonymize IP Addrs
        -b expr BPF program code
        -i addr Ignore this source IP address
        -p      Don't put interface in promiscuous mode
        -r      Redraw interval, in seconds
        -l N    Enable domain stats up to N components
        -f      filter-name

Available filters:
        unknown-tlds
        A-for-A
        rfc1918-ptr

dnstop 실행 옵션의 의미

  • -4: IPv4 패킷만 카운터 (2014년 지금까지 대부분 IPv4를 사용하니 이 옵션을 사용한다.)
  • -6: IPv6 패킷만 카운터(2014년 지금은 IPv6이 거의 사용되지 않는다.)
  • -Q: DNS 쿼리 메시지만 카운터
  • -R: DNS 응답 메시지만 카운터
  • -a: 주소를 익명으로 한다.
  • -b expr: BPF 필터 표현식 (기본 : udp port 53)
  • -i addr: 명시한 IP addr는 제외한다.
  • -n name: 명시한 도메인만 카운터
  • -p: promiscuous mode 로 들어가지 않는다. (서버의 패킷만 보며, 다른 서버의 패킷을 관찰하지 않는다.)
  • -P: 비대화형 모드에서 진행상황 메시지를 보여준다.
  • -r: 새로 그릴 시간(초, 기본 1초)
  • -l N: 도메인을 보여줄 레벨을 설정한다. 1은 TLD이고 보통 3을 설정한다.)
  • -X: 소스IP와 쿼리를 같이 보여주는 모드를 off 한다. (메모리 절약을 위해)
  • -f: 입력 필터 이름
    • 사용가능한 필터는 다음과 같다.
      • unknown-tlds: unknown/invalid TLD(최상위 도메인)
      • A-for-A: 쿼리이름으로 IP를 사용하는 경우
      • rfc1918-ptr: RFC1918 주소공간에 대한 PTR 쿼리
      • refused: REUSED 응답
      • qtype-any: 쿼리 타입이 ANY인 경우

4. dnstop 실행예제

[root@test ~]# dnstop -4 -l 3 eth0

 Queries: 0 new, 18 total                               Wed Dec 10 13:33:29 2014

  Query Type     Count      %
   ---------- --------- ------
  A?                 9   50.0
  PTR?               6   33.3
  AAAA?              3   16.7
  • -4: Ipv4 packet 만 보이기
  • -l: 도메인 레벨 3까지 보이기
  • eth0: NIC eth0으로부터 오는 패킷만 캡쳐.

실행화면에서 "t"키를 누르면 쿼리타입 기준으로 카운터 합니다.

  Queries: 0 new, 31 total                               Wed Dec 10 13:38:41 2014

  Query Type     Count      %
  ---------- --------- ------
  PTR?              22   71.0
  A?                 6   19.4
  AAAA?              3    9.7

실행화면에서 "2"키를 누르면 두번째 도메인까지 기준으로 카운터 한다.

   Queries: 0 new, 31 total                               Wed Dec 10 13:39:31 2014

  Query Name           Count      %
  ---------------- --------- ------
  122.in-addr.arpa        19   61.3
   fs-server.com            9   29.0
   91.in-addr.arpa          3    9.7

참고 싸이트 : https://www.linux.co.kr/home2/board/subbs/board.php?bo_table=lecture&wr_id=1802

문제가 해결되지 않았나요?

궁금하신 사항은 언제든지 1:1 문의게시판으로 문의해 주세요.

문의 시 포함 정보:

  • 카페24 아이디
  • 서비스 ID: 서버호스팅 서비스 ID
  • 서버 OS: CentOS / Ubuntu 등
  • 네트워크 인터페이스: eth0 / eth1 등
  • DNS 서버 IP: DNS 서버 주소
  • 문의 내용: dnstop 설치 및 사용 관련 문의 사항