ntop is a network traffic monitoring tool that shows who is using your bandwidth and how. This guide walks through building ntop from source on CentOS, along with its RRDtool and GeoIP dependencies, opening the firewall, starting it at boot, and turning on the NetFlow collector.
1. Install Build Dependencies and RRDtool
yum install gcc gcc-c++ make libpcap libpcap-devel gdbm-devel libpng-devel libtool libtool-libs rrdtool rrdtool-devel
yum install cairo-devel libxml2-devel pango-devel pango libpng-devel -y
yum install freetype freetype-devel libart_lgpl-devel wget gcc make -y
yum install perl-ExtUtils-MakeMaker -y
yum install graphviz -y
yum install subversion openssl-devel -y
cd /opt
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.5.tar.gz
tar -zxvf rrdtool-1.4.5.tar.gz
cd rrdtool-1.4.5
./configure --prefix=/usr/local/rrdtool
make && make install
2. Build GeoIP
yum install libpcap libpcap-devel gdbm gdbm-devel -y
yum install libevent libevent-devel -y
cd /opt
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.8.tar.gz
tar -zxvf GeoIP-1.4.8.tar.gz
cd GeoIP-1.4.8
./configure
make && make install
3. Build and Install ntop
Download either ntop 5.0.1 (stable) or 4.1.0 (prior stable). The example below uses 4.1.0.
yum install libtool automake autoconf -y
cd /opt
wget http://downloads.sourceforge.net/project/ntop/ntop/Stable/ntop-5.0.1.tar.gz
# or
wget http://downloads.sourceforge.net/project/ntop/ntop/Prior%20Stable/ntop-4.1.0.tar.gz
tar zxvf ntop-4.1.0.tar.gz
cd ntop-4.1.0
./autogen.sh -prefix=/usr/local/ntop
make && make install
make install-selinux-policy
Add /usr/local/ntop/share/man to /etc/man.config, then create the ntop service user and set ownership:
useradd -M -s /sbin/nologin -r ntop
chown ntop:root /usr/local/ntop
chown ntop:ntop /usr/local/ntop/share/ntop
Set the admin password on first run:
cd /usr/local/ntop/bin/
./ntop -u ntop -P /usr/local/ntop -A
4. Open the Firewall (iptables)
The web interface runs on TCP port 3000, and NetFlow traffic arrives on UDP port 9996. Edit /etc/sysconfig/iptables and add these rules before the final INPUT REJECT line:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 9996 -j ACCEPT
service iptables restart
5. Start ntop and Run It at Boot
/usr/local/ntop/bin/ntop -P /usr/local/ntop -u ntop -d -w 3000 -i eth0
Test it by browsing to http://your-server:3000. To start ntop on boot, add the same command to /etc/rc.local.
6. Configure NetFlow and Web Options
The first time you open the ntop web interface:
- Go to Plugins → NetFlow → Activate. Don’t click “Yes” afterward, as that toggles it off again.
- Go to Plugins → NetFlow → View/Configure.
- Create a collector named
eth#-collector, where # is the interface receiving the data.
- Edit the collector: local collector UDP port 9996, flow aggregation none, session handling no, assume FTP no, debug off.
- Go to Admin → Configure → Preferences and set
dot.path to /usr/bin/dot.
- Get a Google Maps API key (browser-referrer key) from the Google API console and set
google_maps.key in the same Preferences screen.
- Stop ntop with
killall ntop, reboot the server, and confirm ntop starts on boot.