Traffic-Accounting mit PMACCT :: Traffic-Accounting installieren und einrichten
Traffic-Accounting mit PMACCT :: Traffic-Accounting installieren und einrichten
So nun kommen wir zum Traffic-Accounting.
Hierfür brauchen wir erstmal aus Lenny ein Paket.
Dafür müssen wir zu erst die sources.list für apt ändern:
von
2
3
4
5
6
7
deb http://ftp.de.debian.org/debian/ etch main contrib non-free
deb-src http://ftp.de.debian.org/debian/ etch main contrib non-free
deb http://security.debian.org/ stable/updates main contrib non-free
deb-src http://security.debian.org/ stable/updates main contrib non-free
deb http://volatile.debian.org/debian-volatile etch/volatile main contrib non-free
nach
2
3
4
5
6
7
deb http://ftp.de.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.de.debian.org/debian/ lenny main contrib non-free
deb http://security.debian.org/ stable/updates main contrib non-free
deb-src http://security.debian.org/ stable/updates main contrib non-free
deb http://volatile.debian.org/debian-volatile etch/volatile main contrib non-free
Nun ein
apt-get update damit wir die aktuellen Pakte bekommen.
Um die Software zu Installieren noch ein
apt-get install pmacct, dies sollte alle benötigten Abhängigkeiten selber installieren.
Danach wechseln wir wieder zurück auf Etch in der sources.list und machen wieder ein
apt-get update, damit wir wieder auf den Etch-Paketen stehen.
Jetzt gehts an die Einrichtung der zweiten Netzwerkkarte und PMACCT.
Da wir eine lauschende Netzwerkkarte brauchen die nicht konfiguriert ist, machen wir folgendes:
nano /etc/rc.localHier tragen wir wie folgt ein:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
ifconfig ethX up
/etc/init.d/pmacct start
exit 0
ethX entspricht Ihre Netzwerkkarte. Als Beispiel, in meinem Server sind eth0 und eth1.
eth0 ist konfiguriert mit einer IP
eth1 lauscht auf den Mirror-Port
Also sieht die Zeile bei mir so aus:
ifconfig eth1 up
So nun rebooten wir den Server neu. Und dann machen wir uns an die Konfiguration von PMACCT.
Mit ifconfig nachschauen ob auch wirklich beide Netzwerkkarten gestartet sind.
Nun verbinden wir die ethX mit dem Mirror-Port.
Kurz zur Kontrolle mal im tcpdump -i ethX geschaut, ob auch der Traffic dort ankommt.
So nun gehen wir an die Einrichtung von PMACCT.
Als erstes richten wir die Datenbank ein.
Hierfür öffnen wir den PHPMyAdmin und erstellen die Datenbank und die Tabelle:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
CREATE DATABASE `pmacct`;
CREATE TABLE `acct` (
`mac_src` char(17) NOT NULL,
`mac_dst` char(17) NOT NULL,
`ip_src` char(15) NOT NULL,
`ip_dst` char(15) NOT NULL,
`src_port` int(2) unsigned NOT NULL,
`dst_port` int(2) unsigned NOT NULL,
`ip_proto` char(6) NOT NULL,
`packets` int(10) unsigned NOT NULL,
`bytes` bigint(20) unsigned NOT NULL,
`stamp_inserted` datetime NOT NULL,
`stamp_updated` datetime default NULL,
PRIMARY KEY (`mac_src`,`mac_dst`,`ip_src`,`ip_dst`,`src_port`,`dst_port`,`ip_proto`,`stamp_inserted`)
);
Die Config-Datei befindet sich: /etc/pmacct/pmacct.conf
Bei der Konfiguration beschränke ich mich auf eine minimale Einrichtung.
nano /etc/pmacct/pmacct.conf
Die Konfiguration sollte nun wie folgt angepasst werden:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
!
! pmacctd configuration example
!
! Did you know CONFIG-KEYS contains the detailed list of all configuration keys
! supported by 'nfacctd' and 'pmacctd' ?
!
! debug: true
interface: ethX
daemonize: true
aggregate: src_host,dst_host,proto
plugins: mysql
sql_host: localhost
sql_db: pmacct
sql_table: acct
sql_table_version: 1
sql_passwd: MYSQLPASSWORT
sql_user: MYSQLUSER
sql_refresh_time: 60
! sql_optimize_clauses: true
sql_history: 5m
sql_history_roundoff: m
syslog: daemon
pmacctd_flow_buffer_buckets: 65536
pmacctd_flow_buffer_size: 128Mb
plugin_pipe_size: 10240000
plugin_buffer_size: 10240
Dies bitte durch ihre eigenen Werte ersetzen:
sql_passwd: MYSQLPASSWORT
sql_user: MYSQLUSER
So jetzt noch ein:
/etc/init.d/pmacct restart
Und wir sind durch. Jetzt sollten sie im 5 Minuten Takt sehen wie im PHPMyAdmin die Datensätze zunehmen.