Ntop 是專門觀察網路使用狀況的工具。互動模式下它把流量統計直接畫在終端;Web 模式下則像一台網頁伺服器,把統計結果以網頁形式送回瀏覽器。
cd /tmp wget -c https://puzzle.dl.sourceforge.net/sourceforge/ntop/ntop-3.2-1.el4.rf.i386.rpm rpm -ivh ntop-3.2-1.el4.rf.i386.rpm
mkdir /var/log/ntop/ cp /etc/ntop.conf.sample /etc/ntop.conf useradd -g ntop -s /bin/true -M ntop
/usr/bin/ntop -P /usr/share/ntop -u ntop -A
-P 指定 .db 存放路徑、-u 指定服務執行身分、-A 用來設定 ntop 內建的 admin 密碼。
首次啟動的完整前置動作可參考:
less /usr/share/doc/ntop-3.0/1STRUN.txt
--interface eth0,lo --local-subnets 192.168.10.0/24 --http-server 3000 --db-file-path /usr/share/ntop --daemon --user ntop --trace-level 3 --disable-schedyield
eth0 是實體網卡、lo 為回送介面;若主機位於路由或閘道上,local-subnets 請改為自己的網段。
/etc/init.d/ntop start # 瀏覽 https://localhost:3000/ # 停止:/etc/init.d/ntop stop
架在 hub 環境下能看到網路上所有封包;架在 switch 上則除非啟用 SPAN(port mirroring),否則只看得到送給自己的流量。另外,因為 ntop 需要監聽埠口,建議用 iptables 限制可存取的來源 IP,避免暴露統計資料。與 MRTG 相比,MRTG 的網頁統計較細緻,Ntop 則在網路層面資訊更完整,兩者用途不同。