Install and configure ntopng for comprehensive network monitoring with traffic analysis and real-time dashboards

Intermediate 45 min May 01, 2026 1,078 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Set up ntopng to monitor network traffic in real-time with detailed analytics, bandwidth monitoring, and customizable dashboards. Learn to configure interface monitoring, traffic analysis rules, and alerting for complete network visibility.

Prerequisites

  • Root or sudo access
  • At least 4GB RAM
  • Network interfaces to monitor
  • Redis for data storage

What this solves

ntopng provides comprehensive network monitoring with real-time traffic analysis, bandwidth usage tracking, and interactive dashboards. You need this when monitoring network performance, identifying bandwidth bottlenecks, analyzing traffic patterns, or tracking network security events across your infrastructure.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you get the latest versions and dependencies.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install ntopng and dependencies

Install ntopng along with required networking tools and Redis for data storage.

sudo apt install -y ntopng redis-server libpcap0.8 net-tools
sudo dnf install -y epel-release
sudo dnf install -y ntopng redis libpcap net-tools

Enable and start Redis

Redis stores ntopng's historical data and provides high-performance data retrieval for dashboards.

sudo systemctl enable --now redis
sudo systemctl status redis

Create ntopng data directory

Set up the directory structure for ntopng data storage with correct permissions.

sudo mkdir -p /var/lib/ntopng
sudo chown ntopng:ntopng /var/lib/ntopng
sudo chmod 755 /var/lib/ntopng

Configure ntopng main settings

Create the primary configuration file with network interfaces, web interface settings, and data storage options.

# Network interfaces to monitor (comma-separated)
-i=eth0,eth1

# Web interface settings
-P=/var/lib/ntopng/ntopng.pid
-d=/var/lib/ntopng
-w=3000

# Redis connection
-r=127.0.0.1:6379

# Local networks (adjust to your subnets)
-m=192.168.1.0/24,10.0.0.0/8,172.16.0.0/12

# Enable historical data
--dump-timeline=1
--dump-flows=1

# User authentication (optional)
-u=admin:admin123

# Logging
-v=3
--syslog=daemon

Configure network interface monitoring

Identify your network interfaces and adjust the monitoring configuration accordingly.

ip link show
ss -tuln | grep :3000

Update the configuration file with your actual interface names:

sudo sed -i 's/eth0,eth1/enp0s3,enp0s8/' /etc/ntopng/ntopng.conf

Set up traffic analysis rules

Create custom rules for traffic categorization and bandwidth monitoring.

# Custom traffic categories
# Format: category_name:protocol:port_range
HTTP_Traffic:tcp:80,8080
HTTPS_Traffic:tcp:443
DNS_Traffic:udp:53
SSH_Traffic:tcp:22
Database_Traffic:tcp:3306,5432
Email_Traffic:tcp:25,587,993,995

Configure alerting and thresholds

Set up bandwidth thresholds and security alerts for network monitoring.

# Bandwidth thresholds (in Mbps)
bandwidth_threshold_host=100
bandwidth_threshold_network=1000

# Flow thresholds
max_flows_per_host=10000
max_new_flows_per_minute=1000

# Security alerts
enable_intrusion_detection=true
enable_malware_detection=true
enable_port_scan_detection=true

# Alert destinations
alert_email=admin@example.com
alert_syslog=true

Create systemd service override

Configure systemd service parameters for better resource management and monitoring.

sudo mkdir -p /etc/systemd/system/ntopng.service.d
[Service]
ExecStart=
ExecStart=/usr/bin/ntopng /etc/ntopng/ntopng.conf
Restart=always
RestartSec=10
User=ntopng
Group=ntopng

[Unit]
After=redis.service
Requires=redis.service

Configure firewall access

Open the ntopng web interface port while maintaining security.

sudo ufw allow 3000/tcp comment 'ntopng web interface'
sudo ufw reload
sudo firewall-cmd --add-port=3000/tcp --permanent
sudo firewall-cmd --reload

Enable and start ntopng

Start the ntopng service and enable it for automatic startup.

sudo systemctl daemon-reload
sudo systemctl enable --now ntopng
sudo systemctl status ntopng

Set up log rotation

Configure automatic log rotation to prevent disk space issues.

/var/log/ntopng/*.log {
    daily
    rotate 30
    compress
    delaycompress
    missingok
    notifempty
    create 644 ntopng ntopng
    postrotate
        /bin/systemctl reload ntopng > /dev/null 2>&1 || true
    endscript
}

Configure dashboards and visualization

Access the web interface

Open your browser and navigate to the ntopng web interface to configure dashboards.

curl -I http://localhost:3000
echo "Access ntopng at: http://$(hostname -I | awk '{print $1}'):3000"

Configure custom dashboard settings

Set up the web interface with custom views and monitoring preferences through the API.

# Create custom dashboard configuration
sudo mkdir -p /var/lib/ntopng/dashboards
sudo tee /var/lib/ntopng/dashboards/custom.json > /dev/null << 'EOF'
{
  "name": "Network Overview",
  "widgets": [
    {
      "type": "traffic_stats",
      "title": "Interface Traffic",
      "interfaces": ["all"]
    },
    {
      "type": "top_talkers",
      "title": "Top 10 Hosts by Traffic",
      "limit": 10
    },
    {
      "type": "protocols",
      "title": "Protocol Distribution"
    }
  ]
}
EOF
sudo chown ntopng:ntopng /var/lib/ntopng/dashboards/custom.json

Set up advanced monitoring and alerts

Configure SNMP integration

Enable SNMP monitoring for network devices and enhanced visibility.

# SNMP device monitoring
# Format: device_ip:community:version
192.168.1.1:public:v2c
192.168.1.10:public:v2c

# SNMP polling interval (seconds)
snmp_polling_interval=300

# SNMP timeout (seconds)
snmp_timeout=10

Update the main configuration to include SNMP monitoring:

echo '--snmp-config=/etc/ntopng/snmp.conf' | sudo tee -a /etc/ntopng/ntopng.conf

Set up email alerting

Configure email notifications for critical network events and threshold breaches.

sudo apt install -y mailutils postfix
sudo dnf install -y mailx postfix
#!/bin/bash
# Email alert script for ntopng

SMTP_SERVER="smtp.example.com"
FROM_EMAIL="ntopng@example.com"
TO_EMAIL="admin@example.com"

# Function to send alert email
send_alert() {
    local subject="$1"
    local message="$2"
    
    echo "$message" | mail -s "[NTOPNG ALERT] $subject" \
        -r "$FROM_EMAIL" \
        -S smtp="$SMTP_SERVER" \
        "$TO_EMAIL"
}

# Check for high bandwidth usage
check_bandwidth() {
    local threshold=1000  # Mbps
    local current=$(curl -s "http://localhost:3000/lua/rest/get/interface/data.lua" | jq -r '.throughput_bps' | awk '{print $1/1000000}')
    
    if (( $(echo "$current > $threshold" | bc -l) )); then
        send_alert "High Bandwidth Usage" "Current bandwidth: ${current}Mbps exceeds threshold: ${threshold}Mbps"
    fi
}

# Run checks
check_bandwidth
sudo chmod +x /etc/ntopng/email-alerts.sh
sudo chown ntopng:ntopng /etc/ntopng/email-alerts.sh

Create monitoring cron jobs

Set up automated monitoring tasks and alert checking.

# Add cron job for ntopng user
sudo crontab -u ntopng -l 2>/dev/null | { cat; echo "*/5 * * * * /etc/ntopng/email-alerts.sh"; } | sudo crontab -u ntopng -

# Verify cron job
sudo crontab -u ntopng -l

Integrate with external monitoring

Configure ntopng to export metrics to external monitoring systems like Prometheus.

# Enable Prometheus metrics export
echo '--prometheus=9090' | sudo tee -a /etc/ntopng/ntopng.conf

# Restart ntopng to apply changes
sudo systemctl restart ntopng

Verify your setup

# Check ntopng service status
sudo systemctl status ntopng

# Verify web interface is accessible
curl -I http://localhost:3000

# Check Redis connection
redis-cli ping

# Verify network interfaces are being monitored
sudo ss -tuln | grep :3000

# Check ntopng logs for errors
sudo journalctl -u ntopng --no-pager -l

# Test Prometheus metrics endpoint (if enabled)
curl http://localhost:9090/metrics | head -20

You can also integrate ntopng metrics with comprehensive monitoring solutions. For example, you can monitor system time drift with Prometheus and Grafana alerts alongside your network monitoring, or set up Linux network traffic shaping with tc and QoS for bandwidth management based on ntopng insights.

Common issues

SymptomCauseFix
ntopng won't startPermission denied on data directorysudo chown -R ntopng:ntopng /var/lib/ntopng
No traffic visibleWrong network interface specifiedCheck ip link show and update -i parameter in config
Web interface not accessibleFirewall blocking port 3000Open port: sudo ufw allow 3000/tcp
Redis connection failedRedis service not runningsudo systemctl start redis
High memory usageToo many flows being trackedReduce --max-num-flows in config
Missing historical dataDump options not enabledAdd --dump-timeline=1 to config
SNMP monitoring not workingSNMP community string incorrectVerify SNMP settings on target devices
Never use chmod 777. If you encounter permission issues, fix ownership with chown and use appropriate permissions like 755 for directories and 644 for files. This maintains security while allowing proper access.

Next steps

Running this in production?

Want this handled for you? Setting up network monitoring once is straightforward. Keeping it tuned, maintaining historical data, managing alerts across environments, and ensuring 24/7 visibility is the harder part. See how we run infrastructure like this for European teams.

Automated install script

Run this to automate the entire setup

Don't want to manage this yourself?

We handle infrastructure for businesses that depend on uptime. Fully managed, with one fixed contact who knows your setup.

You get one fixed contact who knows your setup

Rotterdam 01:28 · reachable in a message, no ticket form