{"id":889,"date":"2014-06-18T01:43:01","date_gmt":"2014-06-18T04:43:01","guid":{"rendered":"http:\/\/www.viazap.com.br\/?p=889"},"modified":"2014-06-18T01:44:42","modified_gmt":"2014-06-18T04:44:42","slug":"install-ntop-on-debian-and-configure-to-use-netflow-on-mikrotik-routeros","status":"publish","type":"post","link":"https:\/\/blog.clusterweb.com.br\/?p=889","title":{"rendered":"Install NTOP on Debian and Configure to Use NetFlow on Mikrotik RouterOS"},"content":{"rendered":"<div class=\"entry-content\" style=\"color: #000000;\">\n<p style=\"font-weight: inherit; font-style: inherit;\"><a style=\"font-weight: inherit; font-style: inherit; color: #666666;\" href=\"http:\/\/www.ntop.org\/products\/ntop\/\" target=\"_blank\">Ntop<\/a>\u00a0is a network monitoring tool similar to Unix top, which shows network traffic usage. It can act\u00a0as a NetFlow collector for flows generated by routers such as Cisco or Mikrotik. NetFlow is an industry standard for flow-based traffic monitoring.<\/p>\n<p style=\"font-weight: inherit; font-style: inherit;\">We will install and configure Ntop to collect flows generated by Mikrotik router.\u00a0<strong style=\"font-style: inherit;\">Note:<\/strong>\u00a0\u201cNtop\u201d != \u201cNtopNG\u201d.<\/p>\n<h2 style=\"font-weight: inherit; font-style: inherit;\">Install Pre-required Software<\/h2>\n<p style=\"font-weight: inherit; font-style: inherit;\">We\u2019re using Debian Wheezy:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"><strong style=\"font-style: inherit;\">$ uname -rv<\/strong>\r\n3.2.0-4-686-pae #1 SMP Debian 3.2.51-1<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Update the system first:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># apt-get update &amp;&amp; apt-get upgrade -uV<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Install required software:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># apt-get install libtool automake autoconf make build-essential python-dev subversion<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Install external tools and libraries required by ntop:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># apt-get install libpcap-dev libgdbm-dev zlib1g-dev libgeoip-dev libgraphviz-dev \\\r\n&gt; graphviz rrdtool librrd-dev<\/pre>\n<p><!--more--><\/p>\n<h2 style=\"font-weight: inherit; font-style: inherit;\">Ntop Installation via Source Code<\/h2>\n<p style=\"font-weight: inherit; font-style: inherit;\">Download the source package:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># cd ~ ; wget http:\/\/sourceforge.net\/projects\/ntop\/files\/ntop\/Stable\/ntop-5.0.1.tar.gz<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Extract the archive:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># tar xvfz ntop-5.0.1.tar.gz &amp;&amp; cd ntop-5.0.1<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Configure, compile and install ntop:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># .\/autogen.sh\r\n# make\r\n# make install<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Create a new system account for ntop:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># useradd -r -s \/bin\/false ntop<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Change ownership appropriately:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># chown -R ntop:ntop \/usr\/local\/share\/ntop \/usr\/local\/lib\/ntop \/usr\/local\/var\/ntop<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Update links and cache to the shared libraries:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># \/sbin\/ldconfig<\/pre>\n<h2 style=\"font-weight: inherit; font-style: inherit;\">Start Ntop as a Daemon<\/h2>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># ntop -cd -i eth0 -u ntop -W 0.0.0.0:3001 -m 10.132.1.0\/24<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">-c :\u00a0prevent idle hosts from being purged from memory<br \/>\n-d : causes ntop to become a daemon<br \/>\n-i : specifies the network interface to use<br \/>\n-u :\u00a0the user ntop should run as after it initialises (but must be started as root)<br \/>\n-W : starts\u00a0an embedded ntop web server for HTTPS<br \/>\n-m : specifies local subnets<\/p>\n<p style=\"font-weight: inherit; font-style: inherit;\">Use\u00a0<em style=\"font-weight: inherit;\">man ntop<\/em>\u00a0for more command line options if needed. Also note that port 3001 needs to opened on a firewall if public access is needed.<\/p>\n<h2 style=\"font-weight: inherit; font-style: inherit;\">Troubleshooting Ntop<\/h2>\n<p style=\"font-weight: inherit; font-style: inherit;\">If you get the error message below when launching ntop:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"><span style=\"font-weight: inherit; font-style: inherit; color: #800000;\"><em style=\"font-weight: inherit;\">error while loading shared libraries: libntopreport-5.0.1.so: cannot open shared object file: No such file or directory<\/em><\/span><\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Update links and cache to the shared libraries:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># \/sbin\/ldconfig<\/pre>\n<h2 style=\"font-weight: inherit; font-style: inherit;\">Enable and Configure NetFlow Plugin on Ntop<\/h2>\n<p style=\"font-weight: inherit; font-style: inherit;\">Connect to ntop web interface here:<\/p>\n<p style=\"font-weight: inherit; font-style: inherit;\"><code>https:\/\/localhost:3001<\/code><\/p>\n<p style=\"font-weight: inherit; font-style: inherit;\">Active NetFlow plugin:\u00a0<strong style=\"font-style: inherit;\"><em style=\"font-weight: inherit;\">\u201cPlugins\u201d -&gt; \u201cNetFlow\u201d -&gt; \u201cActivate\u201d<\/em><\/strong>.<\/p>\n<p style=\"font-weight: inherit; font-style: inherit;\">Open NetFlow configuration panel:<em style=\"font-weight: inherit;\">\u00a0<strong style=\"font-style: inherit;\">\u201cPlugins\u201d -&gt; \u201cNetFlow\u201d -&gt; \u201cConfigure\u201d<\/strong>.<\/em><\/p>\n<p style=\"font-weight: inherit; font-style: inherit;\">Click Add NetFlow Device and fill in the following:<\/p>\n<ol style=\"font-weight: inherit; font-style: inherit;\">\n<li style=\"font-weight: inherit; font-style: inherit;\">NetFlow Device: \u201cMikrotik\u201d<\/li>\n<li style=\"font-weight: inherit; font-style: inherit;\">Local Collector UDP Port: 2055<\/li>\n<li style=\"font-weight: inherit; font-style: inherit;\">Virtual NetFlow Interface Network Address: 10.132.1.0\/24\u00a0<em style=\"font-weight: inherit;\">(change appropriately!)<\/em><\/li>\n<\/ol>\n<p style=\"font-weight: inherit; font-style: inherit;\"><a style=\"font-weight: inherit; font-style: inherit; color: #666666;\" href=\"https:\/\/www.lisenet.com\/wp-content\/uploads\/2014\/01\/ntop-netflow.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1125\" src=\"http:\/\/www.lisenet.com\/wp-content\/uploads\/2014\/01\/ntop-netflow-1024x281.png\" alt=\"\" width=\"654\" height=\"179\" \/><\/a><\/p>\n<h2 style=\"font-weight: inherit; font-style: inherit;\">Enable and Configure NetFlow on Mikrotik RouterOS<\/h2>\n<p style=\"font-weight: inherit; font-style: inherit;\">Enabling traffic flow on the Mikrotik can be done via SSH:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"><span style=\"font-weight: inherit; font-style: inherit; color: #008000;\">[sandy@mikrotik] &gt; <\/span>\/ip traffic-flow \r\n<span style=\"font-weight: inherit; font-style: inherit; color: #008000;\">[sandy@mikrotik] \/ip traffic-flow&gt; <\/span>set enabled=yes interfaces=all<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Print current configuration:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"><span style=\"font-weight: inherit; font-style: inherit; color: #008000;\">[sandy@mikrotik]\u00a0\/ip traffic-flow&gt;<\/span> print\r\n enabled: yes\r\n interfaces: all\r\n cache-entries: 4k\r\n active-flow-timeout: 30m\r\n inactive-flow-timeout: 15s<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Add NetFlow target (our Debian machine):<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"><span style=\"font-weight: inherit; font-style: inherit; color: #008000;\">[sandy@mikrotik]\u00a0\/ip traffic-flow&gt;<\/span> \/ip traffic-flow target\r\n<span style=\"font-weight: inherit; font-style: inherit; color: #008000;\">[sandy@mikrotik]\u00a0\/ip traffic-flow target&gt;<\/span> add address=10.132.1.27:2055 disabled=no version=5<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">Print target configuration:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"><span style=\"font-weight: inherit; font-style: inherit; color: #008000;\">[sandy@mikrotik]\u00a0\/ip traffic-flow target&gt;<\/span> print \r\nFlags: X - disabled \r\n # ADDRESS VERSION\r\n 0 10.132.1.27:2055 5<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">That\u2019s it, now we have to wait a couple of minutes and review data in the ntop web interface.<\/p>\n<h2 style=\"font-weight: inherit; font-style: inherit;\">Ntop WebUI Report<\/h2>\n<div id=\"bottom\" style=\"font-weight: inherit; font-style: inherit;\">\n<pre id=\"footer\" style=\"font-weight: inherit; font-style: inherit;\">Report created on Sun Jan 12 15:28:19 2014 [ntop uptime: 44:04]\u00a0\r\nGenerated by ntop v.5.0.1 (32 bit) [i686-pc-linux-gnu]\r\n\u00a9 1998-2012 by Luca Deri, built: Jan 11 2014 23:13:11.\r\nVersion: the <span style=\"font-weight: inherit; font-style: inherit; color: #0000ff;\">CURRENT stable version<\/span>\r\nListening on [eth0,Mikrotik] for all packets (i.e. without a filtering expression)\u00a0\r\nWeb reports include only interface \"Mikrotik\"<\/pre>\n<\/div>\n<h2 style=\"font-weight: inherit; font-style: inherit;\">Troubleshooting Usage<\/h2>\n<h3 style=\"font-weight: inherit; font-style: inherit;\"><span style=\"font-weight: inherit; font-style: inherit; color: #800000;\"><em style=\"font-weight: inherit;\">**WARNING** INIT: Unable to create pid file (\/usr\/local\/var\/ntop\/ntop.pid)<\/em><\/span><\/h3>\n<p style=\"font-weight: inherit; font-style: inherit;\">Make sure ntop user is the owner of the directory (so can write to it):<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># chown ntop \/usr\/local\/var\/ntop<\/pre>\n<h3 style=\"font-weight: inherit; font-style: inherit;\"><span style=\"font-weight: inherit; font-style: inherit; color: #800000;\"><em style=\"font-weight: inherit;\">**ERROR** RRD: Disabled \u2013 unable to create base directory (err 13, \/usr\/local\/var\/ntop\/rrd)<\/em><\/span><\/h3>\n<p style=\"font-weight: inherit; font-style: inherit;\">The directory may not exist, so create it and change ownership to ntop user:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># mkdir \/usr\/local\/var\/ntop\/rrd\r\n# chown -R ntop \/usr\/local\/var\/ntop\/rrd\/<\/pre>\n<h3 style=\"font-weight: inherit; font-style: inherit;\"><em style=\"font-weight: inherit;\"><span style=\"font-weight: inherit; font-style: inherit; color: #800000;\">ERROR: Missing dot tool (expected \/usr\/local\/bin\/dot). Please set its path (key dot.path) here.<\/span><\/em><\/h3>\n<p style=\"font-weight: inherit; font-style: inherit;\">This may occur trying to use a \u201cLocal Network Traffic Map\u201d when dot is not found. Find out where dot is:<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"><strong style=\"font-style: inherit;\"># which dot<\/strong>\r\n\/usr\/bin\/dot<\/pre>\n<p style=\"font-weight: inherit; font-style: inherit;\">And create a symlink (or alternatively\u00a0edit preferences under\u00a0<code>https:\/\/localhost:3001\/editPrefs.html<\/code>):<\/p>\n<pre style=\"font-weight: inherit; font-style: inherit;\"># ln -s \/usr\/bin\/dot \/usr\/local\/bin\/dot<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Ntop\u00a0is a network monitoring tool similar to Unix top, which shows network traffic usage. It can act\u00a0as a NetFlow collector for flows generated by routers such as Cisco or Mikrotik. NetFlow is an industry standard for flow-based traffic monitoring. We will install and configure Ntop to collect flows generated by Mikrotik router.\u00a0Note:\u00a0\u201cNtop\u201d != \u201cNtopNG\u201d. Install [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[455,1,42,51,415,495,68,271],"tags":[621,292,291,623,619,620,624,622],"class_list":["post-889","post","type-post","status-publish","format-standard","hentry","category-apache2","category-viazap","category-leitura-recomendada","category-linux-linuxrs","category-mikrotik-2","category-profissional-de-ti","category-redes-2","category-seguranca-2","tag-and","tag-configure","tag-install","tag-netflow","tag-ntop","tag-on-debian","tag-on-mikrotik-routeros","tag-to-use"],"_links":{"self":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=889"}],"version-history":[{"count":2,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/889\/revisions"}],"predecessor-version":[{"id":891,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/889\/revisions\/891"}],"wp:attachment":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}