910 likes | 1.1k Views
Flow-tools Tutorial. Mark Fullmer maf@splintered.net. Agenda. Network flows Cisco / Juniper implementation – NetFlow Cisco / Juniper Configuration flow-tools programs overview and examples from Abilene and Ohio-Gigapop. Network Flows. Packets or frames that have a common attribute.
E N D
Flow-tools Tutorial Mark Fullmer maf@splintered.net
Agenda • Network flows • Cisco / Juniper implementation – NetFlow • Cisco / Juniper Configuration • flow-tools programs overview and examples from Abilene and Ohio-Gigapop
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.
Unidirectional Flow with Source/Destination IP Key % telnet 10.0.0.2 login: 10.0.0.1 10.0.0.2 Active Flows Flow Source IP Destination IP • 10.0.0.1 10.0.0.2 • 10.0.0.2 10.0.0.1
Unidirectional Flow with Source/Destination IP Key % telnet 10.0.0.2 % ping 10.0.0.2 login: 10.0.0.1 10.0.0.2 ICMP echo reply Active Flows Flow Source IP Destination IP • 10.0.0.1 10.0.0.2 • 10.0.0.2 10.0.0.1
Unidirectional Flow with IP, Port,Protocol Key % telnet 10.0.0.2 % ping 10.0.0.2 login: 10.0.0.1 10.0.0.2 ICMP echo reply Active Flows Flow Source IP Destination IP prot srcPort dstPort • 10.0.0.1 10.0.0.2 TCP 32000 23 • 10.0.0.2 10.0.0.1 TCP 23 32000 • 10.0.0.1 10.0.0.2 ICMP 0 0 • 10.0.0.2 10.0.0.1 ICMP 0 0
Bidirectional Flow with IP, Port,Protocol Key % telnet 10.0.0.2 % ping 10.0.0.2 login: 10.0.0.1 10.0.0.2 ICMP echo reply Active Flows Flow Source IP Destination IP prot srcPort dstPort • 10.0.0.1 10.0.0.2 TCP 32000 23 • 10.0.0.1 10.0.0.2 ICMP 0 0
Application Flow Web server on Port 9090 % netscape http://10.0.0.2/9090 10.0.0.1 10.0.0.2 Content-type: Active Flows Flow Source IP Destination IP Application • 10.0.0.1 10.0.0.2 HTTP
Aggregated Flow Main Active flow table Flow Source IP Destination IP prot srcPort dstPort • 10.0.0.1 10.0.0.2 TCP 32000 23 • 10.0.0.2 10.0.0.1 TCP 23 32000 • 10.0.0.1 10.0.0.2 ICMP 0 0 • 10.0.0.2 10.0.0.1 ICMP 0 0 Source/Destination IP Aggregate Flow Source IP Destination IP • 10.0.0.1 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.
Campus Passive Monitor Collection Workstation A Workstation B Flow probe connected to switch port in “ traffic mirror” mode
LAN LAN LAN LAN Internet Router Collection Flow collector stores exported flows from router.
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.
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 flows. • The “version” defines what type of data is in the flow. • Some versions specific to Catalyst platform.
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
NetFlow Packet Format • Common header among export versions. • All but v1 have a sequence number. • Version specific data field where N records of data type are exported. • N is determined by the size of the flow definition. Packet size is kept under ~1480 bytes. No fragmentation on Ethernet.
NetFlow v5 Packet Example IP/UDP packet NetFlow v5 header v5 record … … v5 record
NetFlow v5 Packet (Header) struct ftpdu_v5 { /* 24 byte header */ u_int16 version; /* 5 */ 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_int16 reserved;
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]; };
NetFlow v8 Packet Example(AS Aggregation) IP/UDP packet NetFlow v8 header v8 record … … 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]; };
Cisco IOS Configuration • Configured on each input interface. • Define the version. • Define the IP address of the collector (where to send the flows). • Optionally enable aggregation tables. • Optionally configure flow timeout and main (v5) flow table size. • Optionally configure sample rate.
Cisco IOS Configuration interface FastEthernet0/0/0 ip address 10.0.0.1 255.255.255.0 no ip directed-broadcast ip route-cache flow interface ATM1/0/0 no ip address no ip directed-broadcast ip route-cache flow interface Loopback0 ip address 10.10.10.10 255.255.255.255 no ip directed-broadcast ip flow-export version 5 origin-as ip flow-export destination 10.0.0.10 5004 ip flow-export source loopback 0 ip flow-aggregation cache prefix export destination 10.0.0.10 5555 enabled
Cisco IOS Configuration krc4#sh ip flow export Flow export is enabled Exporting flows to 10.0.0.10 (5004) Exporting using source IP address 10.10.10.10 Version 5 flow records, origin-as Cache for prefix aggregation: Exporting flows to 10.0.0.10 (5555) Exporting using source IP address 10.10.10.10 3176848179 flows exported in 105898459 udp datagrams 0 flows failed due to lack of export packet 45 export packets were sent up to process level 0 export packets were punted to the RP 5 export packets were dropped due to no fib 31 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 0 export packets were dropped enqueuing for the RP 0 export packets were dropped due to IPC rate limiting 0 export packets were dropped due to output drops
Cisco IOS Configuration krc4#sho ip ca fl IP packet size distribution (106519M total packets): 1-32 64 96 128 160 192 224 256 288 320 352 384 416 448 480 .002 .405 .076 .017 .011 .010 .007 .005 .004 .005 .004 .004 .003 .002 .002 512 544 576 1024 1536 2048 2560 3072 3584 4096 4608 .002 .006 .024 .032 .368 .000 .000 .000 .000 .000 .000 IP Flow Switching Cache, 4456704 bytes 36418 active, 29118 inactive, 3141073565 added 3132256745 ager polls, 0 flow alloc failures Active flows timeout in 30 minutes Inactive flows timeout in 15 seconds last clearing of statistics never Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec) -------- Flows /Sec /Flow /Pkt /Sec /Flow /Flow TCP-Telnet 2951815 0.6 61 216 42.2 26.6 21.4 TCP-FTP 24128311 5.6 71 748 402.3 15.0 26.3 TCP-FTPD 2865416 0.6 916 843 611.6 34.7 19.8 TCP-WWW 467748914 108.9 15 566 1675.8 4.9 21.6 TCP-SMTP 46697428 10.8 14 370 159.6 4.0 20.1 TCP-X 521071 0.1 203 608 24.7 24.5 24.2 TCP-BGP 2835505 0.6 5 94 3.3 16.2 20.7
Cisco IOS Configuration krc4#sho ip ca fl TCP-other 1620253066 377.2 47 631 18001.6 27.3 23.4 UDP-DNS 125622144 29.2 2 78 82.5 4.6 24.7 UDP-NTP 67332976 15.6 1 76 22.0 2.7 23.4 UDP-TFTP 37173 0.0 2 76 0.0 4.1 24.6 UDP-Frag 68421 0.0 474 900 7.5 111.7 21.6 UDP-other 493337764 114.8 17 479 1990.3 3.8 20.2 ICMP 243659509 56.7 3 166 179.7 3.3 23.3 IGMP 18601 0.0 96 35 0.4 941.4 8.1 IPINIP 12246 0.0 69 52 0.1 548.4 15.2 GRE 125763 0.0 235 156 6.9 50.3 21.1 IP-other 75976755 17.6 2 78 45.4 3.9 22.8 Total: 3176854246 739.6 33 619 24797.4 16.2 22.6 SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts AT5/0/0.4 206.21.162.150 AT1/0/0.1 141.219.73.45 06 0E4B A029 507 AT4/0/0.10 132.235.174.9 AT1/0/0.1 137.99.166.126 06 04BE 074C 3 AT4/0/0.12 131.123.59.33 AT1/0/0.1 137.229.58.168 06 04BE 09BB 646 AT1/0/0.1 137.99.166.126 AT4/0/0.10 132.235.174.9 06 074C 04BE 3
Cisco CatIOS Configuration set mls flow full set mls nde version 7 set mls nde 10.0.0.10 9110 set mls agingtime 32
Cisco CatIOS Configuration swlap1> sh mls Total packets switched = 5116997156 Total bytes switched = 2289120109999 Total routes = 2283 IP statistics flows aging time = 32 seconds IP statistics flows fast aging time = 0 seconds, packet threshold = 0 IP Current flow mask is Full flow Netflow Data Export version: 8 Netflow Data Export disabled Netflow Data Export configured for port 9110 on host 10.0.0.10 Total packets exported = 6545 IPX statistics flows aging time = 256 seconds IPX flow mask is Destination flow IPX max hop is 255 Module 15: Physical MAC-Address 00-04-9b-78-bb-fc
Cisco CatIOS Configuration swlap1> sh mls stat entry Last Used Destination IP Source IP Prot DstPrt SrcPrt Stat-Pkts Stat-Bytes ---------------- --------------- ----- ------ ------ ---------- --------- 64.219.177.137 206.21.217.6 TCP 2206 WWW 4 1113 207.254.193.44 198.30.37.194 TCP 56403 WWW 9 10567 198.30.37.19 66.183.100.164 TCP WWW 1604 4 731 192.88.193.144 199.218.4.130 UDP DNS 61449 1 71 192.88.193.144 199.218.5.131 TCP DNS 2157 5 235 199.218.4.3 208.249.92.145 TCP WWW 37519 6 506 12.42.50.51 198.30.37.19 TCP 11200 WWW 5 494 199.218.5.130 142.22.16.54 TCP WWW 54658 6 745 207.254.193.44 198.30.37.194 TCP 56391 WWW 40 50762 206.21.0.139 24.178.12.64 TCP 110 1085 8 484 217.10.162.50 199.218.5.130 TCP 46983 WWW 53 73775 65.224.146.242 198.30.37.19 TCP 2282 WWW 4 390 199.218.4.135 65.31.16.245 TCP WWW 1196 6 650 24.150.19.19 205.133.123.10 TCP 58043 WWW 4 176
Cisco Catalyst Native IOS Configuration mls flow ip destination-source mls nde flow include mls nde src_address 10.0.0.9 version 7 ip flow-export source Loopback0 ip flow-export version 5 peer-as ip flow-export destination 10.0.0.5 5555
Cisco Issues • Cat 65K Sup2/MSFC2 NetFlow implementation does not fill in important fields like input/output interface. Bug Id : CSCdt21216 Headline Netflow records source / dst interface index missing Product cat6000 Model x6k-sup2 Component earl Duplicate of Severity 3 Status C Version Found 6.1(1) Fixed-in Version 6.2(1) 6.1(3) 6.3(1)PAN Release Notes On Sup2, the destination and source Interface indices would be reported as zero in netflow exports. This is a hardware limitation.
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; } } } } firewall { filter all { term all { then { sample; accept; } } } }
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 flow-capture. • Used when managing disk space in a distributed environment.
Abilene Configuration • Collect and process flows for Abilene routers. • Use sampled NetFlow. • Distribute flows to Asta and Arbor Networks. • Nightly usage reports. • Archive of raw anonymized flows.
Asta Arbor Internet2.edu Ohio ITEC Abilene Configuration Server running flow-fanout @ IU NetFlow exports (UDP) 12 Abilene core routers Configured with sampled NetFlow Post Processed NetFlow (ssh)
Ohio ITEC Abilene Configuration NetFlow exports Pull compressed flow files with rsync from collectors. 4 servers running flow-capture Server with RAID5 Array / web server for nightly reports. flow-expire to manage disk space