You are on page 1of 91

Netow, Flow-tools tutorial

Gaurab Raj Upadhaya

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Agenda
Agenda bashing
Do you want to see the labs, or want to discuss issues

Netflow
What it is and how it works Uses and Applications Vendor Configurations/ Implementation
Cisco and Juniper

Flow-tools
Architectural issues Software, tools etc
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Net-ow

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Network Flows
Packets or frames that have a common attribute. Creation and expiration policy what conditions start and stop a ow. Counters packets,bytes,time. Routing information AS, network mask, interfaces.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Network Flows
Unidirectional or bidirectional. Bidirectional ows can contain other information such as round trip time, TCP behavior. Application ows look past the headers to classify packets by their contents. Aggregated ows ows of ows.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Unidirectional Flow with Source/Destination IP Key


% telnet 10.0.0.2 10.0.0.1 login: 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

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Unidirectional Flow with Source/Destination IP Key


% telnet 10.0.0.2 % ping 10.0.0.2 10.0.0.1 login: ICMP echo reply 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

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Unidirectional Flow with IP, Port,Protocol Key


% telnet 10.0.0.2 % ping 10.0.0.2 10.0.0.1 login: ICMP echo reply Active Flows Flow Source IP 1 2 3 4 10.0.0.1 10.0.0.2 10.0.0.1 10.0.0.2 Destination IP prot 10.0.0.2 10.0.0.1 10.0.0.2 10.0.0.1 srcPort dstPort TCP TCP ICMP ICMP 32000 23 0 0 23 32000 0 0 10.0.0.2

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Bidirectional Flow with IP, Port,Protocol Key


% telnet 10.0.0.2 % ping 10.0.0.2 10.0.0.1 login: ICMP echo reply 10.0.0.2

Active Flows
Flow Source IP dstPort Destination IP prot srcPort

1 10.0.0.1 2 10.0.0.1

10.0.0.2 10.0.0.2

TCP 32000 23 ICMP 0 0

SANOG X Workshop : 29 September -7 August 2007, New Delhi

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

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Aggregated Flow
Main Active ow table
Flow Source IP Destination IP prot srcPort dstPort

1 10.0.0.1 2 10.0.0.2 32000 3 10.0.0.1 4 10.0.0.2


Flow Source IP

10.0.0.2 10.0.0.1 10.0.0.2 10.0.0.1


Destination IP

TCP TCP

32000 23 23 0 0

ICMP 0 ICMP 0

Source/Destination IP Aggregate
10.0.0.2 10.0.0.1

1 10.0.0.1 2 10.0.0.2

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Working with Flows


Generating and Viewing Flows Exporting Flows from devices
Types of flows Sampling rates

Collecting it
Tools to Collect Flows - Flow-tools

Analyzing it
More tools available, can write your own
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Flow Descriptors
A Key with more elements will generate more ows. Greater number of ows leads to more post processing time to generate reports, more memory and CPU requirements for device generating ows. Depends on application. Traffic engineering vs. intrusion detection.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Flow Accounting
Accounting information accumulated with ows. Packets, Bytes, Start Time, End Time. Network routing information masks and autonomous system number.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Flow Generation/Collection
Passive monitor
A passive monitor (usually a unix host) receives all data and generates ows. Resource intensive, newer investments needed

Router or other existing network device.


Router or other existing devices like switch, generate ows. Sampling is possible Nothing new needed
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Passive Monitor Collection

Workstation A

Workstation B

Flow probe connected to switch port in traffic mirror mode

Campus

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Router Collection
LAN LAN

LAN

LAN

Internet Flow collector stores exported ows from router.


SANOG X Workshop : 29 September -7 August 2007, New Delhi

Passive Monitor
Directly connected to a LAN segment via a switch port in mirror mode, optical splitter, or repeated segment. Generate ows for all local LAN traffic. Must have an interface or monitor deployed on each LAN segment. Support for more detailed ows bidirectional and application.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Router Collection
Router will generate ows for traffic that is directed to the router. Flows are not generated for local LAN traffic. Limited to simple ow criteria (packet headers). Generally easier to deploy no new equipment.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Vendor implementations

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco NetFlow
Unidirectional ows. IPv4 unicast and multicast. Aggregated and unaggregated. Flows exported via UDP. Supported on IOS and CatIOS platforms. Catalyst NetFlow is different implementation.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco NetFlow Versions


4 Unaggregated types (1,5,6,7). 14 Aggregated types (8.x). Each version has its own packet format. Version 1 does not have sequence numbers no way to detect lost ows. The version denes what type of data is in the ow. Some versions specic to Catalyst platform.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v1
Key elds: Source/Destination IP, Source/Destination Port, IP Protocol, ToS, Input interface. Accounting: Packets, Octets, Start/ End time, Output interface Other: Bitwise OR of TCP ags.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v5
Key elds: Source/Destination IP, Source/Destination Port, IP Protocol, ToS, Input interface. Accounting: Packets, Octets, Start/ End time, Output interface. Other: Bitwise OR of TCP ags, Source/Destination AS and IP Mask. Packet format adds sequence numbers for detecting lost exports.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v8
Aggregated v5 ows. 3 Catalyst 65xx specic that correspond to the congurable ow mask. Much less data to post process, but lose ne granularity of v5 no IP addresses.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v8
AS Protocol/Port Source Prex Destination Prex Prex Destination (Catalyst 65xx) Source/Destination (Catalyst 65xx) Full Flow (Catalyst 65xx)
SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v8
ToS/AS ToS/Protocol/Port ToS/Source Prex ToS/Destination Prex Tos/Source/Destination Prex ToS/Prex/Port

SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow Packet Format


Common header among export versions. All but v1 have a sequence number. Version specic data eld where N records of data type are exported. N is determined by the size of the ow denition. Packet size is kept under ~1480 bytes. No fragmentation on Ethernet.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v5 Packet Example


IP/UDP packet NetFlow v5 header v5 record v5 record
SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v5 Packet (Header)


struct ftpdu_v5 { /* 24 byte header */ u_int16 version; u_int16 count; u_int32 sysUpTime; u_int32 unix_secs; u_int32 unix_nsecs; u_int32 flow_sequence; u_int8 engine_type; u_int8 engine_id; u_int16 reserved; /* /* /* /* /* /* /* /* 5 */ The number of records in the PDU */ Current time in millisecs since router booted */ Current seconds since 0000 UTC 1970 */ Residual nanoseconds since 0000 UTC 1970 */ Seq counter of total flows seen */ Type of flow switching engine (RP,VIP,etc.) */ Slot number of the flow switching engine */

SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v5 Packet (Records)


/* 48 byte payload */ struct ftrec_v5 { u_int32 srcaddr; /* Source IP Address */ u_int32 dstaddr; /* Destination IP Address */ u_int32 nexthop; /* Next hop router's IP Address */ u_int16 input; /* Input interface index */ u_int16 output; /* Output interface index */ u_int32 dPkts; /* Packets sent in Duration */ u_int32 dOctets; /* Octets sent in Duration. */ u_int32 First; /* SysUptime at start of flow */ u_int32 Last; /* and of last packet of flow */ u_int16 srcport; /* TCP/UDP source port number or equivalent */ u_int16 dstport; /* TCP/UDP destination port number or equiv */ u_int8 pad; u_int8 tcp_flags; /* Cumulative OR of tcp flags */ u_int8 prot; /* IP protocol, e.g., 6=TCP, 17=UDP, ... */ u_int8 tos; /* IP Type-of-Service */ u_int16 src_as; /* originating AS of source address */ u_int16 dst_as; /* originating AS of destination address */ u_int8 src_mask; /* source address prefix mask bits */ u_int8 dst_mask; /* destination address prefix mask bits */ u_int16 drops; } records[FT_PDU_V5_MAXFLOWS]; };
SANOG X Workshop : 29 September -7 August 2007, New Delhi

NetFlow v8 Packet Example (AS Aggregation)


IP/UDP packet NetFlow v8 header v8 record
SANOG X Workshop : 29 September -7 August 2007, New Delhi

v8 record

NetFlow v8 AS agg. Packet


struct ftpdu_v8_1 { /* 28 byte header */ u_int16 version; /* 8 */ u_int16 count; /* The number of records in the PDU */ u_int32 sysUpTime; /* Current time in millisecs since router booted */ u_int32 unix_secs; /* Current seconds since 0000 UTC 1970 */ u_int32 unix_nsecs; /* Residual nanoseconds since 0000 UTC 1970 */ u_int32 flow_sequence; /* Seq counter of total flows seen */ u_int8 engine_type; /* Type of flow switching engine (RP,VIP,etc.) */ u_int8 engine_id; /* Slot number of the flow switching engine */ u_int8 aggregation; /* Aggregation method being used */ u_int8 agg_version; /* Version of the aggregation export */ u_int32 reserved; /* 28 byte payload */ struct ftrec_v8_1 { u_int32 dFlows; /* Number of flows */ u_int32 dPkts; /* Packets sent in duration */ u_int32 dOctets; /* Octets sent in duration */ u_int32 First; /* SysUpTime at start of flow */ u_int32 Last; /* and of last packet of flow */ u_int16 src_as; /* originating AS of source address */ u_int16 dst_as; /* originating AS of destination address */ u_int16 input; /* input interface index */ u_int16 output; /* output interface index */ } records[FT_PDU_V8_1_MAXFLOWS]; };
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco IOS Conguration


Congured on each input interface. Dene the version. Dene the IP address of the collector (where to send the ows). Optionally enable aggregation tables. Optionally congure ow timeout and main (v5) ow table size. Optionally congure sample rate.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco IOS Conguration


interface FastEthernet0/0 ip address 203.94.88.1 255.255.255.0 no ip proxy-arp ip route-cache ow duplex auto speed auto ! interface FastEthernet0/1 ip address 203.94.89.1 255.255.255.0 no ip proxy-arp ip route-cache ow duplex auto speed auto ip ow-export version 5 origin-as ip ow-export destination 203.94.88.2 5004 ip ow-aggregation cache prex export destination 203.94.88.2 5555 enabled

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco IOS Conguration


Change in command in newer IOS
interface FastEthernet0/0 ip route-cache flow ! Prior to IOS 12.4 ip flow [ingress|egress] ! From IOS 12.4

CEF is preferred else netow helps in optimal switching With CEF, netow becomes a information tool

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco IOS Conguration


sanog_sri_lanka#sh ip flow export Flow export v5 is enabled for main cache Exporting flows to 203.94.88.2 (5004) Exporting using source IP address 203.94.88.1 Version 5 flow records, origin-as Cache for prefix aggregation: Exporting flows to 203.94.88.2 (5555) Exporting using source IP address 203.94.88.1 14042 flows exported in 506 udp datagrams 0 flows failed due to lack of export packet 0 export packets were sent up to process level 0 export packets were dropped due to no fib 0 export packets were dropped due to adjacency issues 0 export packets were dropped due to fragmentation failures 0 export packets were dropped due to encapsulation fixup failures

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco IOS Conguration


sanog_sri_lanka#sh ip cache ow IP packet size distribution (37483277 total packets): 132 64 96 128 160 192 224 256 288 320 352 384 416 448 480 .002 .530 .053 .021 .008 .004 .016 .002 .001 .002 .001 .002 .004 .002 .002 512 544 576 1024 1536 2048 2560 3072 3584 4096 4608 .009 .003 .006 .013 .308 .000 .000 .000 .000 .000 .000 IP Flow Switching Cache, 278544 bytes 213 active, 3883 inactive, 7519099 added 150463429 ager polls, 0 ow alloc failures Active ows timeout in 30 minutes Inactive ows timeout in 15 seconds IP Sub Flow Cache, 21640 bytes 213 active, 811 inactive, 14698 added, 14698 added to ow 0 alloc failures, 0 force free 1 chunk, 3 chunks added last clearing of statistics never

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco IOS Conguration


Protocol TCP-Telnet TCP-FTP TCP-FTPD TCP-WWW TCP-SMTP TCP-X TCP-NNTP TCP-Frag TCP-other UDP-DNS UDP-NTP UDP-Frag UDP-other ICMP IP-other Total: SrcIf Se7/1:1 Se7/1:1 Se7/1:1 Se7/1:1 Se7/1:1 Se7/1:1 Se7/1:1 Total Flows Packets Bytes Packets Active(Sec) Idle(Sec) Flows /Sec /Flow /Pkt /Sec /Flow /Flow 307 0.0 50 55 0.0 19.9 12.9 2250 0.0 10 88 0.0 5.7 6.8 552 0.0 458 933 0.4 9.3 2.9 5178673 9.8 4 577 43.7 5.2 14.0 55358 0.1 18 72 1.9 9.8 4.4 15828 0.0 1 40 0.0 0.0 15.3 76 0.0 1 58 0.0 2.9 12.2 137 0.0 1 40 0.0 0.0 15.5 953957 1.8 9 522 16.8 4.1 13.4 15916 0.0 2 66 0.0 3.2 15.5 943 0.0 1 76 0.0 0.0 15.5 76 0.0 1 315 0.0 0.4 15.4 979044 1.8 3 344 6.1 0.7 15.5 315068 0.6 2 64 1.3 1.7 15.4 1671 0.0 265 453 0.8 53.3 15.3 7519856 14.3 4 520 71.5 4.4 14.1 SrcIPaddress 66.199.224.39 121.23.95.181 64.56.64.123 24.86.44.68 64.56.64.123 64.56.64.123 64.56.64.123 DstIf Null Null Null Fa0/1 Null Null Null DstIPaddress 203.94.89.22 203.94.88.192 203.94.89.5 203.94.89.104 203.94.89.32 203.94.89.34 203.94.89.33 Pr 06 06 06 11 06 06 06 SrcP 94E8 0E15 0862 890E 0815 0816 0814 DstP 0050 0050 0050 DB36 0050 0050 0050 Pkts 4 3 2 1 2 2 2

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco IOS Conguration


ip flow-top-talkers top 10 sort-by bytes cache-timeout 3000

sanog_sri_lanka#sh ip flow top-talkers SrcIf Se7/1:1 Se7/1:1 Se7/1:1 Fa0/0 Se7/1:1 Se7/1:1 Se7/1:1 Fa0/1 Fa0/1 Se7/1:1 10 of 10 top SrcIPaddress DstIf DstIPaddress 64.224.10.20 Fa0/0 203.94.88.203 64.224.10.20 Fa0/0 203.94.88.203 213.200.111.46 Fa0/0 203.94.88.93 203.94.88.2 Local 203.94.88.1 213.200.111.56 Fa0/0 203.94.88.93 83.57.179.179 Fa0/1 203.94.89.14 213.200.111.46 Fa0/0 203.94.88.93 203.94.89.93 Null 203.94.89.255 203.94.89.14 Local 203.94.89.1 83.57.179.179 Null 203.94.89.197 talkers shown. 248 flows processed. Pr 06 06 06 01 06 06 06 11 06 06 SrcP 0050 0050 0050 0000 0050 0E8E 0050 0436 DF1E 0DCF DstP Bytes 0877 165K 0876 110K 0612 57K 0303 46K 0610 24K 0050 22K 0613 21K 0089 20K 0017 16K 0050 11K

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco command summary


Enable CEF
ip cef

Enable flow on each interface


ip route cache ow OR ip ow ingress ip ow egress

View flows
show ip cache ow show ip ow top-talkers
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Cisco Command Summary


Exporting Flows to a collector
ip flow-export version 5 [origin-as|peer-as] ip flow-export destination x.x.x.x <udp-port>

Exporting aggregated ows


ip flow-aggregation cache as|prefix|dest|source|proto enabled export destination x.x.x.x <udp-port>

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Juniper Conguration
Sample packets with rewall lter 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 cowd.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Juniper Congration
Firewall lter Enable sampling / ows
forwarding-options { sampling { input { family inet { rate 100; } } output { cflowd 10.0.0.16{ port 2055; version 5; } } } }

firewall { filter all { term all { then { sample; accept; } } } }

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Juniper Conguration
Apply rewall lter to each interface.
interfaces { ge-0/3/0 { unit 0 { family inet { filter { input all; output all; } address 192.148.244.1/24; } } }

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Flows and Applications

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Uses for Flow


Problem identification / solving
Traffic classification DoS Traceback (some slides by Danny McPherson)

Traffic Analysis
Inter-AS traffic analysis Reporting on application proxies

Accounting
Cross verification from other sources Can cross-check with SNMP data
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Traffic Classication
Based on Protocol, source and destination ports
Protocol identification (TCP, UDP, ICMP) Can define well known ports Can identify well known P2P ports Most common use
Proxy measurement - http , ftp Rate limiting P2P traffic
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Traceback: Flow-based*
Trace attack by matching fingerprint/signature at each interface via passive monitoring: Flow data (e.g., NetFlow, cflowd, sFlow, IPFIX) Span Data PSAMP (Packet Sampling, IETF PSAMP WG) Number of open source and commercial products evolving in market Non-intrusive, widely supported

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Flow-based Detection*
Monitor flows (i.e., Network and Transport Layer transactions) on the network and build baselines for what normal behavior looks like: Per interface Per prefix Per Transport Layer protocol & ports Build time-based buckets (e.g., 5 minutes, 30 minutes, 1 hours, 12 hours, day of week, day of month, day of year)
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Detect Anomalous Events: SQL Slammer Worm*

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Flow-based Detection (cont) *


Once baselines are built anomalous activity can be detected
Pure rate-based (pps or bps) anomalies may be legitimate or malicious Many misuse attacks can be immediately recognized, even without baselines (e.g., TCP SYN or RST floods) Signatures can also be defined to identify interesting transactional data (e.g., proto udp and port 1434 and 404 octets(376 payload) == slammer!) Temporal compound signatures can be defined to detect with higher precision

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Flow-based Commercial Tools*

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Commercial Detection A Large Scale DOS attack*

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Traceback: Commercial*

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Commercial Traceback: More Detail*

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Traffic Analysis
Can see traffic based on source and destination AS
Source and destination AS derived through the routing table on the router Introduces the need to run full mesh BGP at IXPs as well as transit and peering Source and destination prefix based flows can be collected and plotted against external prefix to ASN data
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Accounting
Flow based accounting can be a good supplement to SNMP based accounting.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

SNMP and Flows

Data Courtesy AARNET, Australia and Bruce Morgan SANOG X Workshop : 29 September -7 August 2007, New Delhi

See the ne lines..

Data Courtesy AARNET, Australia and Bruce Morgan SANOG X Workshop : 29 September -7 August 2007, New Delhi

SNMP and Flows

Data Courtesy AARNET, Australia and Bruce Morgan SANOG X Workshop : 29 September -7 August 2007, New Delhi

Flow-tools
Collection of programs to post process Cisco NetFlow compatible ows. Written in C, designed to be fast (scales to large installations). Includes library (ftlib) for custom applications. Installation with congure;make;make install on
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-capture
Collect NetFlow exports and stores to disk. Built in compression. Manages disk space by expiring older ow les at congurable limits. Detects lost ows by missing sequence numbers and stores with ow metadata.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-fanout
Replicate NetFlow UDP streams from one source to many destinations. Destination may be a multicast address.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-expire
Expire (remove) old ow les based on disk usage. Same functionality built in to owcapture. Used when managing disk space in a distributed environment.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Collector Placement and conguration


NetFlow is UDP so the collector should ideally be directly connected to the router to minimize packet loss and IP spoong risks. No ow control. Undersized collector will drop ows. Monitor netstat s | grep buf and congure syslog so dropped ows will be logged.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-print
Formatted output of ow les.
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
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-cat
Concat many ow les or directories of les.
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

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-merge
Flow-merge is similar to ow-cat except it maintains relative ordering of ows when combining the les. Typically used when combining ows from multiple collectors.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-lter
Filter ows 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

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-split
Split ow les into smaller les. Typically used with ow-stat and graphing. For example if ow les are 1 hour and want 5 minute data points in graph, ow-split can take the 1 hour ow les and generate 5 minute les.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-tag
Adds a tag eld to ows based on IP exporter, IP prex, Autonomous System, or next hop. Like ow-lter used with other tools. Used to manage groups of prexes or ASNs.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-header
Display meta information in ow
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 #
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-stat
Generates reports from ow les. 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.
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-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

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-stat Source AS % Total


# # src AS # NSFNETTEST14-AS ONENET-AS-1 UONET UPITT-AS CONCERT OHIOU CMU-ROUTER BOSTONU-AS PURDUE STANFORD UR UMN-AGS-NET-AS RISQ-AS PENN-STATE RIT-ASN flows 6.430 2.914 0.600 1.847 1.786 3.961 1.962 1.503 2.185 2.124 1.809 1.612 1.086 2.845 0.796 octets 6.582 4.417 4.052 3.816 2.931 2.601 2.577 2.126 1.994 1.950 1.919 1.895 1.849 1.641 1.601 packets 7.019 3.529 2.484 2.697 2.391 2.140 2.349 1.665 2.157 2.270 1.652 1.788 1.378 2.666 1.414 duration 5.693 3.566 1.979 2.552 1.955 1.655 2.075 1.914 2.507 2.636 1.532 1.938 1.367 2.190 0.830

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-stat Dest AS % Total


# # dst AS # NSFNETTEST14-AS PENN-STATE CONCERT ONENET-AS-1 STANFORD JANET 0 DFN-WIN-AS CMU-ROUTER UONET PURDUE UMN-AGS-NET-AS UPITT-AS MIT-GATEWAYS RIT-ASN INDIANA-AS flows 6.202 2.037 2.628 2.818 1.915 2.508 0.831 2.349 1.383 0.537 2.029 1.608 1.507 0.677 0.644 0.899 octets 9.564 3.774 3.133 2.434 2.360 2.319 2.187 2.099 2.090 2.067 1.934 1.784 1.707 1.425 1.313 1.285 packets 8.005 2.712 2.888 2.906 2.122 2.150 2.431 1.938 1.972 1.699 1.983 1.664 2.067 1.175 1.243 0.996 duration 6.762 2.153 2.326 3.000 2.195 2.485 2.910 2.359 1.960 1.397 2.177 1.681 2.288 0.806 0.868 0.781

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-stat Src/Dest AS % Total


# # src AS # GEORGIA-TECH NWU-AS UONET UCLA CONCERT BCNET-AS UONET MIT-GATEWAYS ONENET-AS-1 UONET NOAA-AS DENET NSFNETTEST14-AS ITALY-AS NSFNETTEST14-AS UONET dst AS PENN-STATE 0 CONCERT NSFNETTEST14-AS UONET MIT-GATEWAYS 0 STANFORD NSFNETTEST14-AS PENN-STATE NOAA-FSL UONET UC-DOM UONET CONCERT ITALY-AS flows 0.030 0.008 0.064 0.037 0.052 0.019 0.015 0.032 0.140 0.019 0.018 0.032 0.022 0.016 0.322 0.022 octets 0.965 0.734 0.698 0.568 0.543 0.538 0.536 0.477 0.451 0.439 0.438 0.410 0.365 0.358 0.349 0.349 packets 0.459 0.379 0.438 0.269 0.364 0.274 0.318 0.245 0.263 0.200 0.255 0.189 0.244 0.228 0.335 0.210 duration 0.071 0.170 0.290 0.111 0.221 0.134 0.200 0.073 0.159 0.063 0.031 0.188 0.081 0.117 0.228 0.130

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-dscan
DoS detection / network scanning tool. Flag hosts which have ows to many other hosts. Flag hosts which are using a large number of TCP/UDP ports. Works better on smaller networks or with ow-lter to limit traffic. For example lter TCP port 25 to
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-gen
Debugging tool to generate ows.
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

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-send
Transmit ow les with NetFlow protocol to another collector. Can be used to take ow-tools les and send them to other NetFlow compatible collector.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-receive
Like ow-capture but does not manage disk space. Output is to standard out and can be used directly with other ow-tools 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
SANOG X Workshop : 29 September -7 August 2007, New Delhi

flows 1 4 25 1 2 1

ow-import
Import ows from other formats into ow-tools. Currently supports ASCII and cowd formats.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-export
Export ows from ow-tools les to other formats. Currently supports ASCII and cowd formats. ASCII output can be used with perl or other scripting languages (with a performance penalty).
SANOG X Workshop : 29 September -7 August 2007, New Delhi

ow-xlate
Translate ows among NetFlow versions. Originally intended for use with Catalyst switches since they export some ows in version 7 and others in version 5 format.

SANOG X Workshop : 29 September -7 August 2007, New Delhi

Front End applications


Flow-tools is good at collecting raw flows You may need additional tools to generate customized reports Perl applications are very popular.
flowscan.pm Cflow.pm CuGrapher.pl

Integration with RRDTool, MRTG etc. makes it more useful


SANOG X Workshop : 29 September -7 August 2007, New Delhi

What Next
IPFIX (IP Flow Information Exchange)
To make the flow format uniform and make it easier to write analysis tools http://www1.ietf.org/html.charters/ipfixcharter.html Requirements for IP Flow Information Export (RFC 3917) Evaluation of Candidate Protocols for IP Flow Information Export (IPFIX) (RFC 3955)
SANOG X Workshop : 29 September -7 August 2007, New Delhi

References
ow-tools: http:// www.splintered.net/sw/ow-tools NetFlow Applications http:// Netow HOW-TO

www.inmon.com/technology/netowapps.php http://www.linuxgeek.org/netow-howto.php

IETF standards effort: http:// ipx.doit.wisc.edu


SANOG X Workshop : 29 September -7 August 2007, New Delhi

References
ow-tools: http:// www.splintered.net/sw/ow-tools Abilene NetFlow page http:// www.itec.oar.net/abilene-netow Flow-tools mailing list: ow-tools@splintered.net Cisco Centric Open Source Community http://cosinms.sourceforge.net/related.html
SANOG X Workshop : 29 September -7 August 2007, New Delhi

More Info
e-mail : gaurab @ lahai.com Labs and instruction on configuration how to configure Flow-tools, and a few more front end applications are available at On the web : http://lahai.com/netmgmt/
SANOG X Workshop : 29 September -7 August 2007, New Delhi

Acknowledgements
Danny McPherson, Arbor Bruce Morgan, AARNet

SANOG X Workshop : 29 September -7 August 2007, New Delhi