Sharing

2012年2月14日 星期二

網路流量監控 ntop


在 Ubuntu 上安裝 ntop 很方便, 只要透過 apt-get 即可, 中間會要求你輸入 admin 的密碼

wistor@wistor-003:~$ sudo apt-get install ntop
[sudo] password for wistor:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  javascript-common libdbi1 libjs-mochikit librrd4 ntop-data python-mako python-markupsafe ttf-dejavu ttf-dejavu-extra
  wwwconfig-common
Suggested packages:
  graphviz gsfonts geoip-database-contrib python-beaker python-mako-doc mysql-client postgresql-client apache2
The following NEW packages will be installed:
  javascript-common libdbi1 libjs-mochikit librrd4 ntop ntop-data python-mako python-markupsafe ttf-dejavu
  ttf-dejavu-extra wwwconfig-common
0 upgraded, 11 newly installed, 0 to remove and 1 not upgraded.
Need to get 5,864 kB of archives.
After this operation, 16.8 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://tw.archive.ubuntu.com/ubuntu/ oneiric/universe wwwconfig-common all 0.2.2 [18.0 kB]
Get:2 http://tw.archive.ubuntu.com/ubuntu/ oneiric/universe javascript-common all 8 [4,208 B]
Get:3 http://tw.archive.ubuntu.com/ubuntu/ oneiric/main libdbi1 amd64 0.8.4-5.1 [28.5 kB]
Get:4 http://tw.archive.ubuntu.com/ubuntu/ oneiric/universe libjs-mochikit all 1.4.2-3fakesync1 [376 kB]
...
Fetched 5,864 kB in 2s (2,346 kB/s)
Preconfiguring packages ...
Selecting previously deselected package wwwconfig-common.
(Reading database ... 64249 files and directories currently installed.)
Unpacking wwwconfig-common (from .../wwwconfig-common_0.2.2_all.deb) ...
Selecting previously deselected package javascript-common.
Unpacking javascript-common (from .../javascript-common_8_all.deb) ...
Selecting previously deselected package libdbi1.
Unpacking libdbi1 (from .../libdbi1_0.8.4-5.1_amd64.deb) ...
Selecting previously deselected package libjs-mochikit.
Unpacking libjs-mochikit (from .../libjs-mochikit_1.4.2-3fakesync1_all.deb) ...
Selecting previously deselected package librrd4.
Unpacking librrd4 (from .../librrd4_1.4.3-3.1ubuntu2_amd64.deb) ...
Selecting previously deselected package ntop-data.
Unpacking ntop-data (from .../ntop-data_3%3a4.0.3+dfsg1-3build1_all.deb) ...
Selecting previously deselected package python-markupsafe.
Unpacking python-markupsafe (from .../python-markupsafe_0.12-2build1_amd64.deb) ...
Selecting previously deselected package python-mako.
Unpacking python-mako (from .../python-mako_0.4.1-2_all.deb) ...
Selecting previously deselected package ntop.
Unpacking ntop (from .../ntop_3%3a4.0.3+dfsg1-3build1_amd64.deb) ...
Selecting previously deselected package ttf-dejavu-extra.
Unpacking ttf-dejavu-extra (from .../ttf-dejavu-extra_2.33-1ubuntu1_amd64.deb) ...
Selecting previously deselected package ttf-dejavu.
Unpacking ttf-dejavu (from .../ttf-dejavu_2.33-1ubuntu1_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Processing triggers for fontconfig ...
Setting up wwwconfig-common (0.2.2) ...
Setting up javascript-common (8) ...
Setting up libdbi1 (0.8.4-5.1) ...
Setting up libjs-mochikit (1.4.2-3fakesync1) ...
Setting up librrd4 (1.4.3-3.1ubuntu2) ...
Setting up ntop-data (3:4.0.3+dfsg1-3build1) ...
Setting up python-markupsafe (0.12-2build1) ...
Setting up python-mako (0.4.1-2) ...
Setting up ntop (3:4.0.3+dfsg1-3build1) ...
Adding system user: ntop.
Warning: The home dir /var/lib/ntop you specified already exists.
Adding system user `ntop' (UID 106) ...
Adding new group `ntop' (GID 114) ...
Adding new user `ntop' (UID 106) with group `ntop' ...
The home directory `/var/lib/ntop' already exists.  Not copying from `/etc/skel'.
adduser: Warning: The home directory `/var/lib/ntop' does not belong to the user you are currently creating.
Wed Feb 15 14:31:59 2012  NOTE: Interface merge enabled by default
Wed Feb 15 14:31:59 2012  Initializing gdbm databases
Wed Feb 15 14:31:59 2012  Setting administrator password...
Wed Feb 15 14:31:59 2012  Admin user password has been set
Wed Feb 15 14:31:59 2012  Admin password set...
Starting network top daemon: Wed Feb 15 14:32:00 2012  NOTE: Interface merge enabled by default
Wed Feb 15 14:32:00 2012  Initializing gdbm databases
ntop
Setting up ttf-dejavu-extra (2.33-1ubuntu1) ...
Setting up ttf-dejavu (2.33-1ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place


安裝好之後, 預設 port number 是 3000, 所以連到 http://:3000 就可以看到結果



不過馬上就發現怎麼預設是只有 eth0 而已, 如果想要轉換不同的 NIC , 必須修改一下設定檔 /var/lib/ntop/init.cfg

root@wistor-007:/var/lib/ntop$ cat /var/lib/ntop/init.cfg
USER="ntop"
INTERFACES="eth0,eth1"

root@wistor-006:~$ sudo /etc/init.d/ntop restart
Stopping network top daemon: ntop
Starting network top daemon: Wed Feb 15 14:39:35 2012  NOTE: Interface merge enabled by default
Wed Feb 15 14:39:35 2012  Initializing gdbm databases
ntop


重啟之後進入頁面會發現 eth1 也出來了,



接下來記得把 NetFlow Plugin 打開來, 那就可以在 eth0 和 eth1 之間順利轉換








沒有留言: