Flow-Tools Tutorial: Sanog 6 Bhutan
Flow-Tools Tutorial: Sanog 6 Bhutan
SANOG 6 Bhutan
Agenda
Network flows Cisco / Juniper implementation NetFlow Cisco / Juniper Configuration flow-tools programs overview and examples from Abilene and OhioGigapop
Network Flows
Packets or frames that have a common attribute. Creation and expiration policy what conditions start and stop a flow. Counters packets,bytes,time. Routing information AS, network mask, interfaces.
Network Flows
Unidirectional or bidirectional. Bidirectional flows can contain other information such as round trip time, TCP behavior. Application flows look past the headers to classify packets by their contents. Aggregated flows flows of flows.
10.0.0.2
Active Flows
Flow Source IP Destination IP
1 10.0.0.1 2 10.0.0.2
10.0.0.2 10.0.0.1
Active Flows
Flow Source IP Destination IP
1 10.0.0.1 2 10.0.0.2
10.0.0.2 10.0.0.1
Active Flows
Flow Source IP Destination IP prot srcPort dstPort
1 2 3 4
32000 23 0 0
23 32000 0 0
Active Flows
Flow Source IP Destination IP prot srcPort dstPort
1 10.0.0.1 2 10.0.0.1
10.0.0.2 10.0.0.2
Application Flow
% netscape http://10.0.0.2/9090 10.0.0.1 Web server on Port 9090
Content-type:
10.0.0.2
Active Flows
Flow Source IP Destination IP Application
1 10.0.0.1
10.0.0.2
HTTP
Aggregated Flow
Main Active flow table
Flow Source IP Destination IP prot srcPort dstPort
1 2 3 4
32000 23 0 0
23 32000 0 0
Source/Destination IP Aggregate
Flow Source IP Destination IP
1 10.0.0.1 2 10.0.0.2
10.0.0.2 10.0.0.1
Flow Descriptors
A Key with more elements will generate more flows. Greater number of flows leads to more post processing time to generate reports, more memory and CPU requirements for device generating flows. Depends on application. Traffic engineering vs. intrusion detection.
Flow Accounting
Accounting information accumulated with flows. Packets, Bytes, Start Time, End Time. Network routing information masks and autonomous system number.
Flow Collection
Passive monitor. Router other existing network device.
Workstation A
Workstation B
Campus
Router Collection
LAN LAN
LAN
LAN
Passive Monitor
Directly connected to a LAN segment via a switch port in mirror mode, optical splitter, or repeated segment. Generate flows for all local LAN traffic. Must have an interface or monitor deployed on each LAN segment. Support for more detailed flows bidirectional and application.
Router Collection
Router will generate flows for traffic that is directed to the router. Flows are not generated for local LAN traffic. Limited to simple flow criteria (packet headers). Generally easier to deploy no new equipment.
Cisco NetFlow
Unidirectional flows. IPv4 unicast and multicast. Aggregated and unaggregated. Flows exported via UDP. Supported on IOS and CatIOS platforms. Catalyst NetFlow is different implementation.
NetFlow v1
Key fields: Source/Destination IP, Source/Destination Port, IP Protocol, ToS, Input interface. Accounting: Packets, Octets, Start/End time, Output interface Other: Bitwise OR of TCP flags.
NetFlow v5
Key fields: Source/Destination IP, Source/Destination Port, IP Protocol, ToS, Input interface. Accounting: Packets, Octets, Start/End time, Output interface. Other: Bitwise OR of TCP flags, Source/Destination AS and IP Mask. Packet format adds sequence numbers for detecting lost exports.
NetFlow v8
Aggregated v5 flows. 3 Catalyst 65xx specific that correspond to the configurable flow mask. Much less data to post process, but lose fine granularity of v5 no IP addresses.
NetFlow v8
AS Protocol/Port Source Prefix Destination Prefix Prefix Destination (Catalyst 65xx) Source/Destination (Catalyst 65xx) Full Flow (Catalyst 65xx)
NetFlow v8
ToS/AS ToS/Protocol/Port ToS/Source Prefix ToS/Destination Prefix Tos/Source/Destination Prefix ToS/Prefix/Port
Juniper Configration
Sample packets with firewall filter and forward to routing engine. Sampling rate is limited to 7000pps. Fine for traffic engineering, but restrictive for DoS and intrusion detection. Juniper calls NetFlow cflowd.
Juniper Configration
Firewall filter Enable sampling / flows
forwarding-options { sampling { input { family inet { rate 100; } } output { cflowd 10.0.0.16{ port 2055; version 5; } } } }
Juniper Configration
Apply firewall filter to each interface.
interfaces { ge-0/3/0 { unit 0 { family inet { filter { input all; output all; } address 192.148.244.1/24; } } }
Flow-tools
Collection of programs to post process Cisco NetFlow compatible flows. Written in C, designed to be fast (scales to large installations). Includes library (ftlib) for custom applications. Installation with configure;make;make install on most platforms (FreeBSD, Linux, Solaris, BSDi, NetBSD).
flow-capture
Collect NetFlow exports and stores to disk. Built in compression. Manages disk space by expiring older flow files at configurable limits. Detects lost flows by missing sequence numbers and stores with flow metadata.
flow-fanout
Replicate NetFlow UDP streams from one source to many destinations. Destination may be a multicast address.
flow-expire
Expire (remove) old flow files based on disk usage. Same functionality built in to flowcapture. Used when managing disk space in a distributed environment.
flow-print
Formatted output of flow files.
eng1:% flow-print < ft-v05.2002-01-21.093345-0500 | head -15 srcIP dstIP prot srcPort dstPort octets packets 131.238.205.199 194.210.13.1 6 6346 40355 221 5 192.5.110.20 128.195.186.5 17 57040 33468 40 1 128.146.1.7 194.85.127.69 17 53 53 64 1 193.170.62.114 132.235.156.242 6 1453 1214 192 4 134.243.5.160 192.129.25.10 6 80 3360 654 7 132.235.156.242 193.170.62.114 6 1214 1453 160 4 130.206.43.51 130.101.99.107 6 3226 80 96 2 206.244.141.3 128.163.62.17 6 35593 80 739 10 206.244.141.3 128.163.62.17 6 35594 80 577 6 212.33.84.160 132.235.152.47 6 1447 1214 192 4 132.235.157.187 164.58.150.166 6 1214 56938 81 2 129.1.246.97 152.94.20.214 6 4541 6346 912 10 132.235.152.47 212.33.84.160 6 1214 1447 160 4 130.237.131.52 130.101.9.20 6 1246 80 902 15
flow-cat
Concat many flow files or directories of files.
eng1:% ls ft-v05.2002-01-21.160001-0500 ft-v05.2002-01-21.161501-0500 ft-v05.2002-01-21.163001-0500 ft-v05.2002-01-21.164501-0500 eng1:% flow-cat . | flow-print srcIP 138.26.220.46 143.105.55.23 129.15.134.66 132.235.170.19 dstIP 192.5.110.20 18.123.66.15 164.107.69.33 152.30.96.188 prot 17 17 6 6 srcPort 62242 41794 1214 6346 dstPort 33456 41794 2222 1475 octets packets 40 1 40 1 4500 3 128 3 ft-v05.2002-01-21.170001-0500 ft-v05.2002-01-21.171501-0500 ft-v05.2002-01-21.173001-0500 tmp-v05.2002-01-21.174501-0500
flow-merge
Flow-merge is similar to flow-cat except it maintains relative ordering of flows when combining the files. Typically used when combining flows from multiple collectors.
flow-filter
Filter flows based on port, protocol, ASN, IP address, ToS bits, TCP bits, and tags.
eng1% flow-cat . | flow-filter -P119 | flow-print | head -10 srcIP 155.52.46.50 128.223.220.29 155.52.46.50 164.107.115.4 128.223.220.29 128.223.220.29 130.207.244.18 155.52.46.50 198.108.1.146 dstIP 164.107.115.4 129.137.4.135 164.107.115.4 192.58.107.160 129.137.4.135 129.137.4.135 129.22.8.64 164.107.115.4 129.137.4.135 prot 6 6 6 6 6 6 6 6 6 srcPort 33225 52745 33225 60141 52745 52714 36033 33225 17800 dstPort 119 119 119 119 119 119 119 119 119 octets 114 1438382 374 5147961 1356325 561016 30194 130 210720652 packets 2 1022 6 8876 965 398 121 2 216072
flow-split
Split flow files into smaller files. Typically used with flow-stat and graphing. For example if flow files are 1 hour and want 5 minute data points in graph, flow-split can take the 1 hour flow files and generate 5 minute files.
flow-tag
Adds a tag field to flows based on IP exporter, IP prefix, Autonomous System, or next hop. Like flow-filter used with other tools. Used to manage groups of prefixes or ASNs.
flow-header
Display meta information in flow file.
eng1:% flow-header < ft-v05.2002-01-21.093345-0500 # # mode: normal # capture hostname: eng1.oar.net # exporter IP address: 0.0.0.0 # capture start: Mon Jan 21 09:33:45 2002 # capture end: Mon Jan 21 09:45:01 2002 # capture period: 676 seconds # compress: on # byte order: little # stream version: 3 # export version: 5 # lost flows: 0 # corrupt packets: 0 # sequencer resets: 0 # capture flows: 341370 #
flow-stat
Generates reports from flow files. Output is readable and easily imported into graphing programs (gnuplot, etc). IP Address, IP address pairs, ports, packets, bytes, interfaces, next hop, Autonomous System, ToS bits, exporter, and tags.
flow-stat - summary
Total Flows : Total Octets : Total Packets : Total Time (1/1000 secs) (flows): Duration of data (realtime) : Duration of data (1/1000 secs) : Average flow time (1/1000 secs) : Average packet size (octets) : Average flow size (octets) : Average packets per flow : Average flows / second (flow) : Average flows / second (real) : Average Kbits / second (flow) : Average Kbits / second (real) : 24236730 71266806610 109298006 289031186084 86400 88352112 11925.0000 652.0000 2940.0000 4.0000 274.3201 280.5177 6452.9880 6598.7781
flow-dscan
DoS detection / network scanning tool. Flag hosts which have flows to many other hosts. Flag hosts which are using a large number of TCP/UDP ports. Works better on smaller networks or with flow-filter to limit traffic. For example filter TCP port 25 to detect hosts infected with e-mail worm.
flow-gen
Debugging tool to generate flows.
eng1:% flow-gen -V8.1 | flow-print | head -10 srcAS 0 1 2 3 4 5 6 7 8 dstAS 65280 65281 65282 65283 65284 65285 65286 65287 65288 in 0 1 2 3 4 5 6 7 8 out 65280 65281 65282 65283 65284 65285 65286 65287 65288 flows 2 4 6 8 10 12 14 16 18 octets 1 2 3 4 5 6 7 8 9 packets 1 2 3 4 5 6 7 8 9 duration 4294901760 4294901760 4294901760 4294901760 4294901760 4294901760 4294901760 4294901760 4294901760
flow-send
Transmit flow files with NetFlow protocol to another collector. Can be used to take flow-tools files and send them to other NetFlow compatible collector.
flow-receive
Like flow-capture but does not manage disk space. Output is to standard out and can be used directly with other flowtools programs. Typically used for debugging.
eng1:% flow-receive 0/0/5555 | flow-print flow-receive: New exporter: time=1011652474 src_ip=199.18.112.114 dst_ip=199.18.97.102 d_version=8 srcPrefix srcAS dstPrefix dstAS input output 143.105/16 600 128.9/16 4 48 25 140.141/16 600 150.216/16 81 48 25 132.235/16 17135 130.49/17 4130 38 25 131.123/16 11050 129.59/16 7212 42 25 206.21/16 600 128.239/16 11975 48 25 199.218/16 600 128.255/16 3676 48 25
flows 1 4 25 1 2 1
flow-import
Import flows from other formats into flow-tools. Currently supports ASCII and cflowd formats.
flow-export
Export flows from flow-tools files to other formats. Currently supports ASCII and cflowd formats. ASCII output can be used with perl or other scripting languages (with a performance penalty).
flow-xlate
Translate flows among NetFlow versions. Originally intended for use with Catalyst switches since they export some flows in version 7 and others in version 5 format.
References
flow-tools: http://www.splintered.net/sw/flow-tools NetFlow Applications
http://www.inmon.com/technology/netflowapps.php http://www.linuxgeek.org/netflow-howto.php
Netflow HOW-TO
References
flow-tools: http://www.splintered.net/sw/flow-tools Abilene NetFlow page http://www.itec.oar.net/abilene-netflow Flow-tools mailing list: [email protected] Cisco Centric Open Source Community
http://cosi-nms.sourceforge.net/related.html
More Info
e-mail : gaurab @ lahai.com On the web : http://lahai.com/netmgmt/