Ntopng on Debian

Here is description how to install Ntopng on Debian.

ntopng” is an open-source network traffic monitor that shows the network usage, the next generation version of the original ntop.

NEW ntopng v2.4.1

ntopNG Debian repository.

Debian 7 (wheezy)

wget http://apt-stable.ntop.org/wheezy/all/apt-ntop-stable.deb
dpkg -i apt-ntop-stable.deb
grep -q "wheezy-backports" /etc/apt/sources.list || echo "deb http://ftp.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list

Debian 8 (jessie)

wget http://apt-stable.ntop.org/jessie/all/apt-ntop-stable.deb
dpkg -i apt-ntop-stable.deb

apt-get clean all
apt-get update && apt-get upgrade
apt-get install pfring ntopng ntopng-data n2disk

/etc/ntopng/ntopng.conf

--pid=/var/run/ntopng.pid
--community
--dont-change-user
--dump-flows
--dns-mode=1
--data-dir=/disk/temp/ntopng
--disable-login
--disable-alerts
--local-networks=192.168.122.0/25

OLD ntopng v1.2.1

1. Install dependencies
apt-get install autoconf automake autogen libsqlite3-dev libhiredis-dev libtool rrdtool libpcap-dev libglib2.0 libglib2.0-dev libgeoip-dev redis-server wget libxml2-dev build-essential checkinstall

2. Download ntopng

sudo -i
cd /usr/local/src
wget --trust-server-names http://sourceforge.net/projects/ntop/files/ntopng/ntopng-1.2.1.tgz/download

3. Compile ntopng (with geoip database)

tar -zxvf ntopng-1.2.1.tgz
cd ntopng-1.2.1
./autogen.sh
./configure
make geoip
make

4. Create .deb package
./checkinstall

The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]: y

Answer: y

Please write a description for the package.
End your description with an empty line or EOF.
>> ntopng

Type "ntopng".

Continue by pressing ENTER.

New package was automatically installed to your system!

You can remove it using: dpkg -r ntopng

The new package should be located in ntopng folder e.g:
/usr/local/src/ntopng-1.2.1/ntopng_1.2.1-1_amd64.deb

5. Configure ntopng init script

Create ntopng configfile in /etc/default folder and create new folder for logs:

mkdir /var/lib/ntopng
mkdir /var/log/ntopng
touch /var/log/ntopng/startup.log
touch /etc/init.d/ntopng
chmod +x /etc/init.d/ntopng

vi /etc/init.d/ntopng

#! /bin/sh
### BEGIN INIT INFO
# Provides: ntopng
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start ntopng daemon
# Description: Enable services provided by ntopng
### END INIT INFO

DAEMON="/usr/local/bin/ntopng"
NAME="ntopng"
DESC="network top daemon"
INIT="/etc/default/$NAME"
HOMEDIR="/var/lib/ntopng"
LOGDIR="/var/log/ntopng"
SCRIPTNAME=/etc/init.d/$NAME
# The current version of ntopng always creates the pidfile in /var/tmp/ntopng.pid
#PIDFILE=/var/run/ntopng.pid
PIDFILE=/var/tmp/ntopng.pid
INTERFACES=""
ADD_ARGS=""

test -f $DAEMON || exit 0

. /lib/lsb/init-functions

test -f $INIT || exit 0

. $INIT

[ "$ENABLED" = "0" -o "$ENABLED" = "no" -o "$ENABLED" = "n" ] && exit 0

ARGS="--daemon --pid $PIDFILE"

if [ -n "$INTERFACES" ]; then
 for i in $INTERFACES; do
 ARGS="$ARGS -i $i"
 done
fi

if [ -n "$HTTP_PORT" ]; then
 ARGS="$ARGS -w $HTTP_PORT"
fi

ARGS="$ARGS $ADD_ARGS"

ntop_start() {
 /sbin/start-stop-daemon --start --quiet --name $NAME --pidfile $PIDFILE \
 --exec $DAEMON -- $ARGS \
 > /var/log/ntopng/startup.log 2>&1
 retval=$?
 if [ "$retval" -eq 1 ]; then
 log_progress_msg "already running"
 return 0
 fi
 return $retval
}

ntop_stop() {
  /sbin/start-stop-daemon --stop --quiet --oknodo --name $NAME --exec $DAEMON --retry 9 --pidfile $PIDFILE
  return $?
}

case "$1" in
  start)
    log_daemon_msg "Starting $DESC" "$NAME"
    if ntop_start; then
      log_success_msg
    else
      log_failure_msg
    fi
    ;;
  stop)
    log_daemon_msg "Stopping $DESC" "$NAME"
    if ntop_stop; then
      log_success_msg
    else
      log_failure_msg
    fi
    ;;
  restart | force-reload)
    log_daemon_msg "Restarting $DESC" "$NAME"
    if ntop_stop && ntop_start; then
      log_success_msg
    else
      log_failure_msg
    fi
    ;;
  reload | try-restart)
    log_action_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}"

exit 3
 ;;
 status)
 status_of_proc $DAEMON $NAME
 ;;
 *)
 log_action_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}"
 exit 1
 ;;
esac

exit 0

Create a symlink to init script to start the daemon automatically:
update-rc.d ntopng defaults

vi /etc/default/ntopng

ENABLED=1
#Configure network interfaces e.g:.
INTERFACES="eth0 br0"
#Port on which ntopng will listen for the web-UI - default port 3000.
HTTP_PORT=3000
#Additional command-line arguments for ntopng, more: ntopng --help.
ADD_ARGS="--dont-change-user"

6. Start redis-server and ntopng daemons

/etc/init.d/redis-server restart
/etc/init.d/ntopng start

ntopng should listen on TCP/3000 port. Verify this using:
netstat -tlpn | grep ntopng

tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      23285/ntopng

Verify the log for possible errors:
less /var/tmp/ntopng/ntopng.log

7. Accesss to Ntopng:
http://your_server:3000

Username: admin
Password: admin