1 | NetFlow - PortTracker Exercises |
---|
2 | |
---|
3 | # Optional Tasks |
---|
4 | |
---|
5 | ## Installing the PortTracker plugin (Optional or as reference) |
---|
6 | |
---|
7 | First, connect to your virtual machine and become root: |
---|
8 | |
---|
9 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
10 | ssh sysadm@pcN.ws.nsrc.org |
---|
11 | $ sudo bash |
---|
12 | # |
---|
13 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
14 | |
---|
15 | We have installed the nfdump package, but we still need to get the source |
---|
16 | package, as it contains extra files required to enabled PortTracker. |
---|
17 | |
---|
18 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
19 | # cd /usr/local/src |
---|
20 | # wget http://noc.ws.nsrc.org/downloads/nfdump-1.6.6.tar.gz |
---|
21 | # tar xvzf nfdump-1.6.6.tar.gz |
---|
22 | # cd nfdump-1.6.6 |
---|
23 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
24 | |
---|
25 | * Make a directory for the nftrack data |
---|
26 | |
---|
27 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
28 | # mkdir -p /var/log/netflow/porttracker |
---|
29 | # chown www-data /var/log/netflow/porttracker |
---|
30 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
31 | |
---|
32 | * Set the nftrack data directory in the PortTracker.pm module: |
---|
33 | |
---|
34 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
35 | # editor extra/PortTracker.pm |
---|
36 | |
---|
37 | Find the line: |
---|
38 | |
---|
39 | my $PORTSDBDIR = "/data/ports-db"; |
---|
40 | |
---|
41 | and change it to: |
---|
42 | |
---|
43 | my $PORTSDBDIR = "/var/log/netflow/porttracker"; |
---|
44 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
45 | |
---|
46 | Save and exit from the file. |
---|
47 | |
---|
48 | * Install the plugin into the NFSen distribution |
---|
49 | |
---|
50 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
51 | # cp extra/PortTracker.pm /var/nfsen/plugins/ |
---|
52 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
53 | |
---|
54 | * Add the plugin definition to the nfsen.conf configuration |
---|
55 | |
---|
56 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
57 | # cd /var/nfsen/etc |
---|
58 | # editor etc/nfsen.conf |
---|
59 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
60 | |
---|
61 | * Find the plugins section and make it look like this: |
---|
62 | |
---|
63 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
64 | @plugins = ( |
---|
65 | [ 'live', 'PortTracker'], |
---|
66 | ); |
---|
67 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
68 | |
---|
69 | Save and exit from the file. |
---|
70 | |
---|
71 | |
---|
72 | * Initialize the PortTracker database files |
---|
73 | |
---|
74 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
75 | # sudo -u www-data nftrack -I -d /var/log/netflow/porttracker |
---|
76 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
77 | |
---|
78 | (This can take a LONG time! - 8 GB worth of files will be created) |
---|
79 | |
---|
80 | * Set the permissions so the netflow user running nfsen, and the www-data |
---|
81 | user running the Web interface, can access the porttracker data. |
---|
82 | |
---|
83 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
84 | # chown -R netflow:www-data /var/log/netflow/porttracker |
---|
85 | # chmod -R 775 /var/log/netflow/porttracker |
---|
86 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
87 | |
---|
88 | * Restart NfSen |
---|
89 | |
---|
90 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
91 | # service nfsen stop |
---|
92 | # service nfsen start |
---|
93 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
94 | |
---|
95 | * Check for success: |
---|
96 | |
---|
97 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
98 | # grep -i 'porttracker.*success' /var/log/syslog |
---|
99 | Oct 12 13:19:35 pc1 nfsen[28005]: Loading plugin 'PortTracker': Success |
---|
100 | Oct 12 13:19:35 pc1 nfsen[28005]: Initializing plugin 'PortTracker': Success |
---|
101 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
102 | |
---|
103 | * Wait some minutes, and go the the nfsen GUI |
---|
104 | |
---|
105 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
106 | http://pcX.ws.nsrc.org/nfsen/nfsen.php |
---|
107 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
108 | |
---|
109 | ... and select the Plugins tab. |
---|
110 | |
---|
111 | ***************************************************************************** |
---|
112 | * You may get an error that "No plugins installed!" or |
---|
113 | * "Error reading stats"... |
---|
114 | * |
---|
115 | * Don't worry, you need to wait a few minutes before NfSen will begin to |
---|
116 | * show the PortTracker plugin and its graphs. |
---|
117 | ***************************************************************************** |
---|
118 | |
---|
119 | At this point you are done. Congratulations! |
---|
120 | |
---|
121 | |
---|
122 | ## Troubleshooting |
---|
123 | |
---|
124 | If you get an error "Cannot Read Stats file", check the /var/log/netflow/porttracker \ |
---|
125 | directory for 2 additional files: portstat24.txt and portstat.txt like this: |
---|
126 | |
---|
127 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
128 | # ls -l /var/log/netflow/porttracker/portstat* |
---|
129 | -rw-r--r-- 1 netflow www-data 677 2011-11-17 14:30 /var/log/netflow/\ |
---|
130 | porttracker/portstat24.txt |
---|
131 | -rwxrwxr-x 1 netflow www-data 638 2011-11-17 14:30 /var/log/netflow/\ |
---|
132 | porttracker/portstat.txt |
---|
133 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
134 | |
---|
135 | Make sure that nfsen can write in that directory. |
---|