Shell Script To Build dnstop Utility To Displays Various Tables Of DNS Server Traffic

in Categories Software Build Scripts last updated March 5, 2010
# A shell script to build dnstop utility to displays various tables 
# of DNS traffic on your network including bind 9 server stats.
# -------------------------------------------------------------------------
# Tested under CentOS / RHEL / Fedora Linux only.
# -------------------------------------------------------------------------
# Copyright (c) 2008 nixCraft project <>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit for more information.
# -------------------------------------------------------------------------
# Last updated on Mar/05/2010
# -------------------------------------------------------------------------
# Home page:
[[ "$2" != "" ]] && ETH="$2"
[[ `id -u` -ne 0 ]] && { echo "$0: You must be root user to run this script. Run it as 'sudo $0'"; exit 1; }
case "$1" in
        wget $URL -O "${DLHOME}/$FILE"
        echo "Building ${SOFTWARE}...."
        # this needs some improvements, bur right now I am just gonna try to install it ;( 
	yum -y install libpcap-devel ncurses-devel &>/dev/null
        [[ ! -f "${DLHOME}/$FILE" ]] &&  wget $URL -O "${DLHOME}/$FILE"
        cd "${DLHOME}"
        tar -zxvf $FILE
        cd "$DEST"
        make install
        grep -q 'alias dnstop' $HOME/.bashrc        
        [ $? -ne 0 ] && echo "alias dnstop='/usr/local/bin/dnstop -l 6 ${ETH}'" >> $HOME/.bashrc
    *) echo "Usage: $0 {download|build} [eth0|eth1]"


From the man page:

dnstop is a small tool to listen on device or to parse the file savefile and collect and print statistics on the local network’s DNS traffic. You must have read access to /dev/bpf*.

How Do I Use This Script?

Download type the following command:
./ build
/usr/local/bin/dnstop -l 6 eth0

Share this on:

4 comment

  1. The script surely would work only on rpm-based Linuxes, as it uses the “yum” command.
    Maybe if you changed this one line to equivalent apt command…?

    Have a question? Post it on our forum!