您好,登录后才能下订单哦!
# Linux下如何安装网络监控工具ntopng
## 一、ntopng简介
ntopng是一款开源的网络流量监控和分析工具,是经典工具ntop的下一代版本。它能够实时显示网络使用情况,并通过直观的Web界面提供丰富的流量统计信息。
### 主要功能特性:
- 实时流量监控和分析
- 支持IPv4/IPv6网络
- 详细的协议分类统计
- 历史数据存储和趋势分析
- 异常流量检测和告警
- 支持多种操作系统和平台
## 二、安装前准备
### 1. 系统要求
- 操作系统:Ubuntu/Debian/CentOS/RHEL等主流Linux发行版
- 内存:至少2GB(生产环境建议4GB以上)
- 磁盘空间:10GB以上(根据流量规模调整)
- 网络接口:需配置为混杂模式
### 2. 依赖环境检查
安装前需确保系统已安装以下组件:
```bash
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y build-essential libpcap-dev libxml2-dev libsqlite3-dev libhiredis-dev libgeoip-dev libcurl4-openssl-dev libpcre3-dev libtool autoconf automake redis-server wget
# CentOS/RHEL
sudo yum groupinstall -y "Development Tools"
sudo yum install -y libpcap-devel libxml2-devel sqlite-devel hiredis-devel GeoIP-devel curl-devel pcre-devel libtool autoconf automake redis wget
wget https://packages.ntop.org/apt/22.04/all/apt-ntop.deb
sudo apt install ./apt-ntop.deb
sudo apt-get update
sudo apt-get install -y pfring-dkms nprobe ntopng ntopng-data
sudo yum install -y https://packages.ntop.org/centos-stable/centos/7/x86_64/ntop-release-centos-1.0-1.el7.noarch.rpm
sudo yum install -y epel-release
sudo yum install -y pfring-dkms nprobe ntopng ntopng-data
wget https://github.com/ntop/ntopng/archive/refs/tags/5.6.tar.gz
tar xvf 5.6.tar.gz
cd ntopng-5.6
./autogen.sh
./configure
make
sudo make install
git clone https://github.com/ntop/PF_RING.git
cd PF_RING/kernel
make && sudo make install
cd ../userland
./configure && make
sudo make install
编辑配置文件/etc/ntopng/ntopng.conf
:
# 监听接口
-G=/var/run/ntopng.pid
--interface=eth0
--http-port=3000
--https-port=3001
--local-networks="192.168.1.0/24"
--data-dir=/var/lib/ntopng
sudo systemctl enable redis
sudo systemctl start redis
创建/etc/systemd/system/ntopng.service
:
[Unit]
Description=ntopng network monitoring
After=network.target redis.service
[Service]
Type=simple
ExecStart=/usr/bin/ntopng /etc/ntopng/ntopng.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable ntopng
sudo systemctl start ntopng
# 查看状态
sudo systemctl status ntopng
# 停止服务
sudo systemctl stop ntopng
# 重启服务
sudo systemctl restart ntopng
# 查看日志
journalctl -u ntopng -f
http://your_server_ip:3000
或
https://your_server_ip:3001
用户名:admin
密码:admin
--interface=eth0 --interface=eth1
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/ntopng.key -out /etc/ssl/certs/ntopng.crt
然后在配置中添加:
--https-certificate=/etc/ssl/certs/ntopng.crt
--https-certificate-key=/etc/ssl/private/ntopng.key
--mail-server=smtp.example.com
--mail-port=587
--mail-user=ntopng@example.com
--mail-password=your_password
--mail-from=ntopng@example.com
如果3000端口被占用,可以修改:
--http-port=3002
确保数据目录有正确权限:
sudo chown -R ntopng:ntopng /var/lib/ntopng
对于高流量环境,建议:
--max-num-flows=1000000
--zmq-export-flow-url=tcp://127.0.0.1:5556
配置历史数据保留时间(天):
--data-retention=30
配置示例:
--interface=eth0
--local-networks="192.168.1.0/24,10.0.0.0/8"
--disable-login=no
--community
--interface=eth0
--zmq-export-flow-url=tcp://*:5556
--nindex-threshold=100000
--max-num-hosts=50000
配置Logstash接收ntopng日志:
input {
tcp {
port => 5556
codec => json
}
}
使用ntopng的REST API获取数据:
curl -u admin:password http://localhost:3000/lua/rest/v2/get/interface/data.lua
top -p $(pgrep ntopng)
--max-memory=4096
对于大型网络,可考虑: - 前端采集节点 - 中央分析服务器 - 分布式Redis集群
sudo apt-get purge ntopng
sudo apt-get autoremove
sudo yum remove ntopng
sudo make uninstall
sudo rm -rf /var/lib/ntopng
ntopng作为一款功能强大的网络监控工具,通过本文介绍的安装和配置方法,可以帮助管理员有效监控网络流量、分析异常行为。建议:
通过合理配置,ntopng可以成为网络运维中不可或缺的利器,为网络安全和性能优化提供有力支持。
最后更新:2023年11月
适用版本:ntopng 5.x
参考文档:
- 官方文档
- GitHub仓库
“`
这篇文章详细介绍了ntopng的安装配置过程,包含多种安装方式、详细配置步骤、常见问题解决方案以及实际应用案例,全文约2550字,采用Markdown格式编写,可直接用于技术文档发布。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。