| 1 | % Monitoring Netflow with NFsen |
|---|
| 2 | % |
|---|
| 3 | % Network Monitoring and Management |
|---|
| 4 | |
|---|
| 5 | # Introduction |
|---|
| 6 | |
|---|
| 7 | ## Goals |
|---|
| 8 | |
|---|
| 9 | * Learn how to export flows from a Cisco router |
|---|
| 10 | * Learn how to install the Nfsen family of tools |
|---|
| 11 | * Install the optional PortTracker plugin |
|---|
| 12 | |
|---|
| 13 | ## Notes |
|---|
| 14 | |
|---|
| 15 | * Commands preceded with "$" imply that you should execute the command as |
|---|
| 16 | a general user - not as root. |
|---|
| 17 | * Commands preceded with "#" imply that you should be working as root. |
|---|
| 18 | * Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>") |
|---|
| 19 | imply that you are executing commands on remote equipment, or within |
|---|
| 20 | another program. |
|---|
| 21 | |
|---|
| 22 | # Export flows from a Cisco router |
|---|
| 23 | |
|---|
| 24 | This is an example for doing this from the Group 1 router, rtr1.ws.nsrc.org to |
|---|
| 25 | the PC named pc1.ws.nsrc.org or 10.10.1.1. In each of your groups 1 through N |
|---|
| 26 | you must choose one person to type in the commands to set up router for Netflow |
|---|
| 27 | and one PC where the Netflow exports will go. IOS can unfortunately not send |
|---|
| 28 | Netflow messages to more than 1 or 2 devices, so we will use only 1 now. |
|---|
| 29 | |
|---|
| 30 | For example, if our router is rtr1, or 10.10.1.254 (Group 1 gateway): |
|---|
| 31 | |
|---|
| 32 | Assuming you have enabled ssh on the router: |
|---|
| 33 | |
|---|
| 34 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 35 | $ ssh cisco@10.10.1.254 |
|---|
| 36 | rtr1.ws.nsrc.org> enable |
|---|
| 37 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 38 | |
|---|
| 39 | or, if ssh is not configured yet: |
|---|
| 40 | |
|---|
| 41 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 42 | $ telnet 10.10.1.54 |
|---|
| 43 | Username: cisco |
|---|
| 44 | Password: |
|---|
| 45 | Router1>enable |
|---|
| 46 | Password: |
|---|
| 47 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 48 | |
|---|
| 49 | Enter the enable password... |
|---|
| 50 | |
|---|
| 51 | Configure FastEthernet0/0 to generate netflow: |
|---|
| 52 | (substitute X with your group number) |
|---|
| 53 | |
|---|
| 54 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 55 | rtr1.ws.nsrc.org# configure terminal |
|---|
| 56 | rtr1.ws.nsrc.org(config)# interface FastEthernet 0/0 |
|---|
| 57 | rtr1.ws.nsrc.org(config-if)# ip flow ingress |
|---|
| 58 | rtr1.ws.nsrc.org(config-if)# ip flow egress |
|---|
| 59 | rtr1.ws.nsrc.org(config-if)# exit |
|---|
| 60 | rtr1.ws.nsrc.org(config)# ip flow-export destination 10.10.0.254 999X |
|---|
| 61 | rtr1.ws.nsrc.org(config)# ip flow-export version 5 |
|---|
| 62 | rtr1.ws.nsrc.org(config)# ip flow-cache timeout active 5 |
|---|
| 63 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 64 | |
|---|
| 65 | This breaks up long-lived flows into 5-minute fragments. You can |
|---|
| 66 | choose any number of minutes between 1 and 60. If you leave it at |
|---|
| 67 | the default of 30 minutes your traffic reports will have spikes. |
|---|
| 68 | |
|---|
| 69 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 70 | rtr1.ws.nsrc.org(config)# snmp-server ifindex persist |
|---|
| 71 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 72 | |
|---|
| 73 | This enables ifIndex persistence globally. This ensures that the |
|---|
| 74 | ifIndex values are persisted during router reboots. |
|---|
| 75 | |
|---|
| 76 | Now configure how you want the ip flow top-talkers to work: |
|---|
| 77 | |
|---|
| 78 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 79 | rtr1.ws.nsrc.org(config)#ip flow-top-talkers |
|---|
| 80 | rtr1.ws.nsrc.org(config-flow-top-talkers)#top 20 |
|---|
| 81 | rtr1.ws.nsrc.org(config-flow-top-talkers)#sort-by bytes |
|---|
| 82 | rtr1.ws.nsrc.org(config-flow-top-talkers)#end |
|---|
| 83 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 84 | |
|---|
| 85 | Now we'll verify what we've done. |
|---|
| 86 | |
|---|
| 87 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 88 | rtr1.ws.nsrc.org# show ip flow export |
|---|
| 89 | rtr1.ws.nsrc.org# show ip cache flow |
|---|
| 90 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 91 | |
|---|
| 92 | See your "top talkers" across your router interfaces |
|---|
| 93 | |
|---|
| 94 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 95 | rtr1.ws.nsrc.org# show ip flow top-talkers |
|---|
| 96 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 97 | |
|---|
| 98 | If it all looks good then write your running-config to non-volatile |
|---|
| 99 | RAM (i.e. the startup-config): |
|---|
| 100 | |
|---|
| 101 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 102 | rtr1.ws.nsrc.org#wr mem |
|---|
| 103 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 104 | |
|---|
| 105 | You can exit from the router now: |
|---|
| 106 | |
|---|
| 107 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 108 | rtr1.ws.nsrc.org#exit |
|---|
| 109 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 110 | |
|---|
| 111 | We are re-exporting NetFlow data from the gateway router to all the PCs in the |
|---|
| 112 | classroom. You can verify that these flows are arriving by typing: |
|---|
| 113 | |
|---|
| 114 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 115 | $ sudo tcpdump -v udp port 9009 |
|---|
| 116 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 117 | |
|---|
| 118 | And this will show you the flows from the router in your group. |
|---|
| 119 | |
|---|
| 120 | # Configure Your Collector |
|---|
| 121 | |
|---|
| 122 | ## Install NFdump and friends |
|---|
| 123 | |
|---|
| 124 | NFdump is the Netflow flow collector. We install several additional packages |
|---|
| 125 | that we will need a bit later: |
|---|
| 126 | |
|---|
| 127 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 128 | $ sudo apt-get install rrdtool mrtg librrds-perl librrdp-perl librrd-dev \ |
|---|
| 129 | nfdump libmailtools-perl |
|---|
| 130 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 131 | |
|---|
| 132 | This will install, among other things, nfcapd, nfdump, nfreplay, nfexpire, |
|---|
| 133 | nftest, nfgen. |
|---|
| 134 | |
|---|
| 135 | ## Installing and setting up NfSen |
|---|
| 136 | |
|---|
| 137 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 138 | $ cd /usr/local/src |
|---|
| 139 | $ sudo wget http://noc.ws.nsrc.org/downloads/nfsen-latest.tar.gz |
|---|
| 140 | $ sudo tar xvzf nfsen-latest.tar.gz |
|---|
| 141 | $ cd nfsen-VERSION |
|---|
| 142 | $ cd etc |
|---|
| 143 | $ sudo cp nfsen-dist.conf nfsen.conf |
|---|
| 144 | $ sudo editor nfsen.conf |
|---|
| 145 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 146 | |
|---|
| 147 | Set the $BASEDIR variable |
|---|
| 148 | |
|---|
| 149 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 150 | $BASEDIR="/var/nfsen"; |
|---|
| 151 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 152 | |
|---|
| 153 | Adjust the tools path to where items actually reside: |
|---|
| 154 | |
|---|
| 155 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 156 | # nfdump tools path |
|---|
| 157 | $PREFIX = '/usr/bin'; |
|---|
| 158 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 159 | |
|---|
| 160 | Set the users appropriately so that Apache can access files: |
|---|
| 161 | |
|---|
| 162 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 163 | $WWWUSER = 'www-data'; |
|---|
| 164 | $WWWGROUP = 'www-data' |
|---|
| 165 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 166 | |
|---|
| 167 | Set the buffer size to something small, so that we see data quickly |
|---|
| 168 | |
|---|
| 169 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 170 | # Receive buffer size for nfcapd - see man page nfcapd(1) |
|---|
| 171 | $BUFFLEN = 2000; |
|---|
| 172 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 173 | |
|---|
| 174 | Find the %sources definition, and change it to: |
|---|
| 175 | |
|---|
| 176 | (substitute X with your group number). |
|---|
| 177 | |
|---|
| 178 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 179 | %sources=( |
|---|
| 180 | 'rtrX' => {'port'=>'9009','col'=>'#ff0000','type'=>'netflow'}, |
|---|
| 181 | 'gw' => {'port'=>'9900','col'=>'#0000ff','type'=>'netflow'}, |
|---|
| 182 | ); |
|---|
| 183 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 184 | |
|---|
| 185 | Now save and exit from the file. |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | ## Create the netflow user on the system |
|---|
| 189 | |
|---|
| 190 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 191 | $ useradd -d /var/netflow -G www-data -m -s /bin/false netflow |
|---|
| 192 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | ## Initiate NfSen. |
|---|
| 196 | |
|---|
| 197 | Any time you make changes to nfsen.conf you will have to do this step again. |
|---|
| 198 | |
|---|
| 199 | Make sure we are in the right location: |
|---|
| 200 | |
|---|
| 201 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 202 | $ cd /usr/local/src/nfsen-VERSION |
|---|
| 203 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 204 | |
|---|
| 205 | Now, finally, we install: |
|---|
| 206 | |
|---|
| 207 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 208 | $ sudo perl install.pl etc/nfsen.conf |
|---|
| 209 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 210 | |
|---|
| 211 | Start NfSen |
|---|
| 212 | |
|---|
| 213 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 214 | sudo /var/nfsen/bin/nfsen start |
|---|
| 215 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | ## View flows via the web: |
|---|
| 219 | |
|---|
| 220 | Make sure you have PHP installed: |
|---|
| 221 | |
|---|
| 222 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 223 | $ sudo apt-get install php5 |
|---|
| 224 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 225 | |
|---|
| 226 | You can find the nfsen page here: |
|---|
| 227 | |
|---|
| 228 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 229 | http://pcX.ws.nsrc.org/nfsen/nfsen.php |
|---|
| 230 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 231 | |
|---|
| 232 | (Below is only if there are problems) |
|---|
| 233 | |
|---|
| 234 | Note that in /usr/local/src/nfsen-VERSION/etc/nfsen.conf there is a variable |
|---|
| 235 | $HTMLDIR that you may need to configure. By default it is set like this: |
|---|
| 236 | |
|---|
| 237 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 238 | $HTMLDIR="/var/www/nfsen/"; |
|---|
| 239 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 240 | |
|---|
| 241 | In some cases you may need to either move the nfsen directory in your web |
|---|
| 242 | structure, or update the $HTMLDIR variable for your installation. |
|---|
| 243 | |
|---|
| 244 | If you move items, then do: |
|---|
| 245 | |
|---|
| 246 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 247 | $ /etc/init.d/apache2 restart |
|---|
| 248 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | ## Verify that flows are arriving |
|---|
| 252 | |
|---|
| 253 | Assuming that you are exporting flows from a router, or routers, to |
|---|
| 254 | your collector box on port 9009 you can check for arriving data using |
|---|
| 255 | tcpdump: |
|---|
| 256 | |
|---|
| 257 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 258 | $ sudo tcpdump -v udp port 9009 |
|---|
| 259 | $ sudo tcpdump -v udp port 9900 |
|---|
| 260 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 261 | |
|---|
| 262 | ## Install init script |
|---|
| 263 | |
|---|
| 264 | In order to have nfsen start and stop automatically when the system starts, |
|---|
| 265 | add a link to the init.d diretory pointing to the nfsen startup script: |
|---|
| 266 | |
|---|
| 267 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 268 | $ sudo ln -s /var/nfsen/bin/nfsen /etc/init.d/nfsen |
|---|
| 269 | $ update-rc.d nfsen defaults 20 |
|---|
| 270 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 271 | |
|---|
| 272 | |
|---|
| 273 | # Optional Tasks |
|---|
| 274 | |
|---|
| 275 | ## Installing the PortTracker plugin (Optional or as reference) |
|---|
| 276 | |
|---|
| 277 | We need to get nfdump 1.6.5 or newer. The version of nfdump included |
|---|
| 278 | in Ubuntu 10.04 is 1.6.3p1, so that won't work. |
|---|
| 279 | |
|---|
| 280 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 281 | # apt-get install bison flex yacc |
|---|
| 282 | # cd /usr/local/src |
|---|
| 283 | # wget http://noc.ws.nsrc.org/downloads/nfdump-latest.tar.gz |
|---|
| 284 | # tar xvzf nfdump-latest.tar.gz |
|---|
| 285 | # cd nfdump-VERSION |
|---|
| 286 | # ./configure --prefix /usr --enable-nfprofile --enable-nftrack |
|---|
| 287 | # make |
|---|
| 288 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 289 | |
|---|
| 290 | * Make a directory for the nftrack data |
|---|
| 291 | |
|---|
| 292 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 293 | $ mkdir -p /var/log/netflow/porttracker |
|---|
| 294 | $ chown www-data /var/log/netflow/porttracker |
|---|
| 295 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 296 | |
|---|
| 297 | * Set the nftrack data directory in the PortTracker.pm module: |
|---|
| 298 | |
|---|
| 299 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 300 | $ EDITOR PortTracker.pm |
|---|
| 301 | |
|---|
| 302 | Find the line: |
|---|
| 303 | |
|---|
| 304 | my $PORTSDBDIR = "/data/ports-db"; |
|---|
| 305 | |
|---|
| 306 | and change it to: |
|---|
| 307 | |
|---|
| 308 | my $PORTSDBDIR = "/var/log/netflow/porttracker"; |
|---|
| 309 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 310 | |
|---|
| 311 | ... |
|---|
| 312 | |
|---|
| 313 | * Install the plugins into the NFSen distribution |
|---|
| 314 | |
|---|
| 315 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 316 | $ cp PortTracker.pm /var/nfsen/plugins/ |
|---|
| 317 | $ cp PortTracker.php /var/www/nfsen/plugins/ |
|---|
| 318 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 319 | |
|---|
| 320 | * Add the plugin definition to the nfsen.conf configuration |
|---|
| 321 | |
|---|
| 322 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 323 | $ cd /usr/local/src/nfsen-VERSION |
|---|
| 324 | $ EDITOR etc/nfsen.conf |
|---|
| 325 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 326 | |
|---|
| 327 | Find the plugins section and make it look like this: |
|---|
| 328 | |
|---|
| 329 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 330 | @plugins = ( |
|---|
| 331 | [ 'live', 'PortTracker'], |
|---|
| 332 | ); |
|---|
| 333 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 334 | |
|---|
| 335 | ... |
|---|
| 336 | |
|---|
| 337 | * Re-run the installation (answer questions) |
|---|
| 338 | |
|---|
| 339 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 340 | $ perl install.pl etc/nfsen.conf |
|---|
| 341 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 342 | |
|---|
| 343 | * Initialize portracker database files |
|---|
| 344 | |
|---|
| 345 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 346 | $ sudo -u www-data nftrack -I -d /var/log/netflow/porttracker |
|---|
| 347 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 348 | |
|---|
| 349 | (This can take a LONG time! - 8 GB worth of files will be created) |
|---|
| 350 | |
|---|
| 351 | * Set the permissions so the netflow user running nfsen, and the www-data |
|---|
| 352 | user running the Web interface, can access the porttracker data: |
|---|
| 353 | |
|---|
| 354 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 355 | $ chown -R netflow:www-data /var/log/netflow/porttracker |
|---|
| 356 | $ chmod -R 775 /var/log/netflow/porttracker |
|---|
| 357 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 358 | |
|---|
| 359 | * Reload: |
|---|
| 360 | |
|---|
| 361 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 362 | $ /var/nfsen/bin/nfsen reload |
|---|
| 363 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 364 | |
|---|
| 365 | * Check for success: |
|---|
| 366 | |
|---|
| 367 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 368 | $ grep -i 'porttracker.*success' /var/log/syslog |
|---|
| 369 | Nov 27 02:46:13 noc nfsen[17312]: Loading plugin 'PortTracker': Success |
|---|
| 370 | Nov 27 02:46:13 noc nfsen[17312]: Initializing plugin 'PortTracker': Success |
|---|
| 371 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 372 | |
|---|
| 373 | * Wait some minutes, and go the the nfsen GUI |
|---|
| 374 | |
|---|
| 375 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 376 | http://pcX.ws.nsrc.org/nfsen/nfsen.php |
|---|
| 377 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 378 | |
|---|
| 379 | ... and select the Plugins tab. |
|---|
| 380 | |
|---|
| 381 | If you get an error "Cannot Read Stats file", check the /var/log/netflow/porttracker \ |
|---|
| 382 | directory for 2 additional files: portstat24.txt and portstat.txt like this: |
|---|
| 383 | |
|---|
| 384 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 385 | $ ls -l /var/log/netflow/porttracker/portstat* |
|---|
| 386 | -rw-r--r-- 1 netflow www-data 677 2011-11-17 14:30 /var/log/netflow/\ |
|---|
| 387 | porttracker/portstat24.txt |
|---|
| 388 | -rwxrwxr-x 1 netflow www-data 638 2011-11-17 14:30 /var/log/netflow/\ |
|---|
| 389 | porttracker/portstat.txt |
|---|
| 390 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 391 | |
|---|
| 392 | Make sure that nfsen can write in that directory. |
|---|
| 393 | |
|---|
| 394 | ## If you wanted to add more sources... |
|---|
| 395 | |
|---|
| 396 | Go back to where you extracted your nfsen distribution. |
|---|
| 397 | |
|---|
| 398 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 399 | $ cd /usr/local/src/nfsen-VERSION |
|---|
| 400 | $ EDITOR etc/nfsen.conf |
|---|
| 401 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 402 | |
|---|
| 403 | Update your sources for new items that you might have. |
|---|
| 404 | (Sample only!) |
|---|
| 405 | |
|---|
| 406 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 407 | %sources = ( |
|---|
| 408 | 'rtr' => {'port' => '9000', 'col' => 'e4e4e4' }, |
|---|
| 409 | 'rtr2' => { 'port' => '9001', 'col' => '#0000ff' }, |
|---|
| 410 | 'rtr3' => { 'port' => '9002','col' => '#00cc00' }, |
|---|
| 411 | 'rtr4' => { 'port' => '9003','col' => '#000000' }, |
|---|
| 412 | 'rtr5' => { 'port' => '9004','col' => '#ff0000' }, |
|---|
| 413 | 'rtr6' => { 'port' => '9005','col' => '#ffff00' }, |
|---|
| 414 | ); |
|---|
| 415 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 416 | |
|---|
| 417 | Save and exit from the nfsend.conf file. |
|---|
| 418 | |
|---|
| 419 | Remember, you've updated nfsen.conf so you must re-run the install |
|---|
| 420 | script: |
|---|
| 421 | |
|---|
| 422 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 423 | $ perl install.pl etc/nfsen.conf |
|---|
| 424 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 425 | |
|---|
| 426 | Now start and stop nfsen: |
|---|
| 427 | |
|---|
| 428 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 429 | $ sudo service nfsen stop |
|---|
| 430 | $ sudo service nfsen start |
|---|
| 431 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 432 | |
|---|
| 433 | That's it! |
|---|