雷达智富

首页 > 内容 > 程序笔记 > 正文

程序笔记

如何在 Ubuntu 或 Debian Linux 上安装 ntopng

2024-07-25 Linux 43

在今天的文章中,我们将在 Ubuntu 或 Debian Linux 系统上进行 ntopng 的安装和配置。 ntopng 工具在网络流量探测中非常有用,它提供 360° 网络可见性。它可以从各种来源获取流量信息,例如防火墙日志、网络中的流量监视器、NetFlow 导出器、入侵检测系统或 SNMP 设备。它配备了用于管理和分析的加密且直观的 Web 用户界面。

ntopng 可以安装在 Linux、Windows、FreeBSD 和 macOS 上。它使用 libpcap 或 PF_RING(在 Linux 上)捕获来自 SPAN/镜像端口或 TAP 设备的流量,以获得最佳性能。它还可以与 nProbe 结合使用,从路由器和交换机收集 NetFlow/sFlow,或与 nProbe Cento 结合使用,以全速率分析 100 Gbit 链路。

本文将提供 ntopng 在 Ubuntu 或 Debian Linux 计算机上的安装指南。要获取最新的软件包选项,请从官方项目的上游存储库完成安装。

添加 ntopng APT 存储库

更新 APT 包索引并安装关键先决条件。

sudo apt update && sudo apt install software-properties-common wget

接下来,我们通过执行以下命令将存储库添加到系统中。

Ubuntu Linux:

sudo add-apt-repository universe
source /etc/os-release
wget https://packages.ntop.org/apt/$VERSION_ID/all/apt-ntop.deb
sudo apt install ./apt-ntop.deb

Debian Linux:

source /etc/os-release
wget https://packages.ntop.org/apt/$VERSION_CODENAME/all/apt-ntop.deb
sudo apt install ./apt-ntop.deb

它将添加存储库并导入所需的 GPG 密钥。

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'apt-ntop' instead of './apt-ntop.deb'
The following NEW packages will be installed:
  apt-ntop
0 upgraded, 1 newly installed, 0 to remove and 45 not upgraded.
Need to get 0 B/3,370 B of archives.
After this operation, 8,192 B of additional disk space will be used.
Get:1 /root/apt-ntop.deb apt-ntop all 2.10-28 [3,370 B]
Selecting previously unselected package apt-ntop.
(Reading database ... 39498 files and directories currently installed.)
Preparing to unpack /root/apt-ntop.deb ...
Unpacking apt-ntop (2.10-28) ...
Setting up apt-ntop (2.10-28) ...
Installing ntop GPG key [no proxy]. Please wait...
gpg: keybox '/usr/share/keyrings/ntop-archive-keyring.gpg' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 3D84C955924F7599: public key "Luca Deri <[email >" imported
gpg: Total number processed: 1
gpg:               imported: 1
Keys installed successfully
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

在 Ubuntu/Debian 上安装 ntopng

添加存储库后,让我们安装 ntopng 包。

sudo apt update && sudo apt install ntopng

同意安装提示。

...
1 upgraded, 126 newly installed, 0 to remove and 44 not upgraded.
Need to get 214 MB of archives.
After this operation, 771 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

检查服务状态以确认其正在运行。

 $ systemctl status ntopng.service
ntopng.service - ntopng high-speed web-based traffic monitoring and analysis tool
     Loaded: loaded (/etc/systemd/system/ntopng.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2024-02-14 12:29:12 UTC; 2min 1s ago
    Process: 5036 ExecStartPre=/bin/sh -c /usr/bin/ntopng-utils-manage-config -a check-restore  && /usr/bin/ntopng-utils-manage-config -a restore || true (code=exited, status=0/SUCCESS)
    Process: 5051 ExecStartPre=/bin/sh -c /bin/cat /etc/ntopng/ntopng.conf > /run/ntopng.conf.raw (code=exited, status=0/SUCCESS)
    Process: 5053 ExecStartPre=/bin/sh -c /bin/cat /etc/ntopng/ntopng.conf.d/*.conf >> /run/ntopng.conf.raw 2>/dev/null || true (code=exited, status=0/SUCCESS)
    Process: 5056 ExecStartPre=/bin/sh -c /bin/sed "/^[ ]*-e.*$\|^[ ]*-G.*\|^[ ]*--daemon.*\|[ ]*--pid.*/s/^/#/" /run/ntopng.conf.raw > /run/ntopng.conf (code=exited, status=0/SUCCESS)
   Main PID: 5059 (ntopng-main)
      Tasks: 39 (limit: 2244)
     Memory: 221.2M
        CPU: 21.883s
     CGroup: /system.slice/ntopng.service
             └─5059 /usr/bin/ntopng /run/ntopng.conf

Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [PeriodicActivities.cpp:179] Found 10 activities
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NatsBroker.cpp:42] ERROR: NATS Connection to broker [0.0.0.0:4222] failed: (conn.c:1985): No server available for connection
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NatsBroker.cpp:42] ERROR: NATS Connection to broker [0.0.0.0:4222] failed: (conn.c:1985): No server available for connection
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NetworkInterface.cpp:3776] Started packet polling on interface 'lo' [id: 1]...
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NetworkInterface.cpp:3776] Started packet polling on interface 'eth0' [id: 2]...
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NetworkInterface.cpp:2497] Packets exceeding the expected max size have been received [eth0][len: 2906][max len: 1518].
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NetworkInterface.cpp:2503] WARNING: If TSO/GRO is enabled, please disable it for best accuracy
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NetworkInterface.cpp:2503] WARNING: If TSO/GRO is enabled, please disable it for best accuracy
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NetworkInterface.cpp:2507] WARNING: using: sudo ethtool -K eth0 gro off gso off tso off
Feb 14 12:29:22 jammy ntopng[5059]: 14/Feb/2024 12:29:22 [NetworkInterface.cpp:2507] WARNING: using: sudo ethtool -K eth0 gro off gso off tso off

检查 ntopng 使用的端口。

$ sudo ss -tunelp | grep ntop
udp   UNCONN 0      0                 0.0.0.0:33836      0.0.0.0:*    users:(("ntopng-main",pid=5059,fd=24)) ino:36140 sk:1 cgroup:/system.slice/ntopng.service <->
udp   UNCONN 0      0           49.13.172.139:41405      0.0.0.0:*    users:(("ntopng-main",pid=5059,fd=23)) ino:36138 sk:4 cgroup:/system.slice/ntopng.service <->
tcp   LISTEN 0      4096              0.0.0.0:3000       0.0.0.0:*    users:(("ntopng-main",pid=5059,fd=28)) ino:36192 sk:8 cgroup:/system.slice/ntopng.service <->

访问 ntopng 网络仪表板

打开浏览器并输入http://ServerIP:3000/

使用默认登录

  • 用户名:管理员
  • 密码:管理员

您需要更改管理员密码。为用户设置强密码。

最后,您将登陆 ntopng Web 仪表板。

ntopng CLI 用法

当 ntopng 的 systemd 服务未激活时,您可以使用 CLI 方法。

列出您的网络接口:

# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 96:00:03:04:9d:dc brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    altname ens3

要监控物理 NIC 卡,请在运行ntopng时指定其接口名称。

sudo ntopng -i eth0

流量采集

对于网络流量收集,ntopng 需要与 nProbe 结合使用,nProbe 可以充当探针/代理。 nProbentopng 之间的数据交换将通过 ZeroMQ(一种发布-订阅协议)进行。

nprobe -i eth1 --zmq tcp://192.168.1.1:5556 -T @NTOPNG@
ntopng -i tcp://192.168.1.1:5556

重要链接:

  • ntopng github 项目
  • ntopng 许可
  • ntopng 包
  • 官方文档

更新于:1个月前
赞一波!2

文章评论

全部评论