2021/08/04

記錄一下在 ubuntu 20.04 (LXC) 安裝nfsen

OS布署完成後先update

apt update

apt upgrade -y

再來修改時區

timedatectl set-timezone Asia/Taipei


安裝所需 package

apt install -y nfdump rrdtool librrd-dev librrds-perl librrdp-perl libpcap-dev php php-common libsocket6-perl apache2 libapache2-mod-php libmailtools-perl libio-socket-ssl-perl

下載 nfsen

從官方下載的版本在安裝時會出現以下的 bug

Can't use string ("live") as a HASH ref while "strict refs" in use at libexec/NfProfile.pm line 1238.


因此從 https://github.com/p-alik/nfsen/releases/tag/nfsen-1.3.8 下載已修正版本

下載後解壓縮

cd nfsen-nfsen-1.3.8/etc

cp nfsen-dist.conf nfsen.conf

決定安裝路徑在 /opt/nfsen

修改 nfsen.conf

$BASEDIR = "/opt/nfsen";

$PREFIX = '/usr/bin/';

$USER = "www-data";

$WWWUSER = "www-data";

$WWWGROUP = "www-data";

%sources = ( 'upstream1' => {'port'=>'9995','col'=>'#0000ff','type'=>'netflow'}' );


mkdir /opt/nfsen

mkdir /var/www/html/nfsen


adduser netflow


安裝

./install.pl ./etc/nfsen.conf

出現

RRD version '1.7002' not yet supported!


需修改 libexec/NfSenRRD.pm 約在第 76 行 改成 ==> $rrd_version >= 1.2 && $rrd_version < 1.9


再執行一次

./install.pl ./etc/nfsen.conf


啟動

/opt/nfsen/bin/nfsen start


設定開几啟動


cd /etc/systemd/system
ln -s /lib/systemd/system/rc-local.service


vi /etc/rc.local

#!/bin/sh -e

/usr/local/nfsen/bin/nfsen start

exit 0

chmod +x /etc/rc.local 


設定開几不啟動nfdump 因為nfsen啟動時會自行呼叫

systemctl disable nfdump.service


重開几


設定 netflow 導到 udp 9995


打開 http://nfsen_ip/nfsen/nfsen.php 確認是否正常


https://sc8log.blogspot.com/2017/06/ubuntu-1604-netflow.html

https://github.com/p-alik/nfsen/releases/tag/nfsen-1.3.8


https://github.com/p-alik/nfsen/issues/1

https://zoomadmin.com/HowToInstall/UbuntuPackage/libsocket6-perl

沒有留言: