• No results found

Netflow, Flow-tools tutorial

N/A
N/A
Protected

Academic year: 2021

Share "Netflow, Flow-tools tutorial"

Copied!
91
0
0

Loading.... (view fulltext now)

Full text

(1)

Netflow, Flow-tools

tutorial

(2)

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

(3)
(4)

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.

(5)

Network Flows

• Unidirectional or bidirectional.

• Bidirectional flows can contain

other information such as round

trip time, TCP behavior.

• Application flows look past the

(6)

Unidirectional Flow with

Source/Destination IP Key

10.0.0.1

10.0.0.2

% telnet 10.0.0.2

login:

Active Flows

Flow Source IP Destination IP

(7)

Unidirectional Flow with

Source/Destination IP Key

10.0.0.1

10.0.0.2

% telnet 10.0.0.2

login:

Active Flows

Flow Source IP Destination IP

% ping 10.0.0.2

(8)

Unidirectional Flow with IP,

Port,Protocol Key

10.0.0.1

login:

10.0.0.2

Active Flows

Flow Source IP Destination IP prot

srcPort dstPort

1 10.0.0.1

10.0.0.2

TCP

32000 23

2 10.0.0.2

10.0.0.1

TCP

23 32000

3 10.0.0.1

10.0.0.2

ICMP

0 0

4 10.0.0.2

10.0.0.1

ICMP

0 0

% telnet 10.0.0.2

% ping 10.0.0.2

(9)

Bidirectional Flow with IP,

Port,Protocol Key

10.0.0.1

10.0.0.2

% telnet 10.0.0.2

login:

Active Flows

Flow Source IP Destination IP

prot

srcPort

dstPort

1 10.0.0.1

10.0.0.2

TCP 32000 23

% ping 10.0.0.2

(10)

Application Flow

10.0.0.1

10.0.0.2

% netscape http://10.0.0.2/9090

Content-type:

Active Flows

Flow Source IP Destination IP

Application

1 10.0.0.1

10.0.0.2

HTTP

(11)

Aggregated Flow

Flow Source IP Destination IP prot srcPort dstPort

1 10.0.0.1

10.0.0.2

TCP 32000 23

2 10.0.0.2

10.0.0.1

TCP 23

32000

3 10.0.0.1

10.0.0.2

ICMP 0 0

4 10.0.0.2

10.0.0.1

ICMP 0 0

Source/Destination IP Aggregate

Flow Source IP Destination IP

(12)

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

(13)

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

(14)

Flow Accounting

• Accounting information

accumulated with flows.

• Packets, Bytes, Start Time, End

Time.

(15)

Flow Generation/Collection

• Passive monitor

• A passive monitor (usually a unix host)

receives all data and generates flows.

• Resource intensive, newer investments

needed

• Router or other existing network device.

• Router or other existing devices like switch,

generate flows.

(16)

Passive Monitor Collection

Workstation A

Workstation B

Campus

Flow probe connected

to switch port in

(17)
(18)

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 –

(19)

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).

(20)
(21)

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

(22)

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.

(23)

NetFlow v1

• Key fields: Source/Destination IP,

Source/Destination Port, IP

Protocol, ToS, Input interface.

• Accounting: Packets, Octets, Start/

End time, Output interface

(24)

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

(25)

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

(26)
(27)
(28)

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

(29)
(30)

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 */

(31)

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 */

(32)
(33)

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 */

(34)

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.

(35)

Cisco IOS Configuration

interface FastEthernet0/0 ip address 203.94.88.1 255.255.255.0 no ip proxy-arp ip route-cache flow duplex auto speed auto ! interface FastEthernet0/1 ip address 203.94.89.1 255.255.255.0 no ip proxy-arp ip route-cache flow duplex auto speed auto

ip flow-export version 5 origin-as

(36)

Cisco IOS Configuration

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 netflow helps in optimal

switching

(37)

Cisco IOS Configuration

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

(38)

Cisco IOS Configuration

sanog_sri_lanka#sh ip cache flow

IP packet size distribution (37483277 total packets):

1–32 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 flow alloc failures Active flows timeout in 30 minutes

Inactive flows timeout in 15 seconds

IP Sub Flow Cache, 21640 bytes

213 active, 811 inactive, 14698 added, 14698 added to flow 0 alloc failures, 0 force free

1 chunk, 3 chunks added

(39)

Cisco IOS Configuration

Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec) ———— Flows /Sec /Flow /Pkt /Sec /Flow /Flow

(40)

Cisco IOS Configuration

ip flow-top-talkers top 10

sort-by bytes

cache-timeout 3000

sanog_sri_lanka#sh ip flow top-talkers

(41)

Cisco command summary

• Enable CEF

– ip cef

• Enable flow on each interface

ip route cache flow OR

ip flow ingress

ip flow egress

(42)

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 flows

ip flow-aggregation cache as|prefix|dest|source|proto enabled

(43)

Juniper Configuration

• 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.

(44)

Juniper Configration

firewall { filter all { term all { then { sample; accept; } } } } forwarding-options { sampling { input { family inet { rate 100; } } output { cflowd 10.0.0.16{ port 2055; version 5; } } } }

(45)

Juniper Configuration

interfaces { ge-0/3/0 { unit 0 { family inet { filter { input all; output all; } address 192.148.244.1/24; } }

(46)
(47)

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

(48)

Traffic Classification

• 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

(49)

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

(50)

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,

(51)
(52)

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!)

(53)
(54)
(55)
(56)
(57)

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

(58)

Accounting

(59)
(60)

See the fine lines..

(61)
(62)

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

(63)

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

(64)

flow-fanout

• Replicate NetFlow UDP streams

from one source to many

destinations.

(65)

flow-expire

• Expire (remove) old flow files based

on disk usage.

• Same functionality built in to

flow-capture.

(66)

Collector Placement and

configuration

• NetFlow is UDP so the collector

should ideally be directly connected

to the router to minimize packet

loss and IP spoofing risks.

• No flow control. Undersized

collector will drop flows. Monitor

netstat –s | grep buf and configure

syslog so dropped flows will be

(67)

flow-print

• Formatted output of flow files.

eng1:% flow-print < ft-v05.2002-01-21.093345-0500 | head -15

(68)

flow-cat

• Concat many flow files or

directories of files.

eng1:% ls ft-v05.2002-01-21.160001-0500 ft-v05.2002-01-21.170001-0500 ft-v05.2002-01-21.161501-0500 ft-v05.2002-01-21.171501-0500 ft-v05.2002-01-21.163001-0500 ft-v05.2002-01-21.173001-0500 ft-v05.2002-01-21.164501-0500 tmp-v05.2002-01-21.174501-0500 eng1:% flow-cat . | flow-print

(69)

flow-merge

• Flow-merge is similar to flow-cat

except it maintains relative

ordering of flows when combining

the files.

(70)

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

(71)

flow-split

• Split flow files into smaller files.

• Typically used with flow-stat and

(72)

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.

(73)

flow-header

• Display meta information in flow

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

(74)

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

(75)

flow-stat - summary

Total Flows : 24236730 Total Octets : 71266806610 Total Packets : 109298006 Total Time (1/1000 secs) (flows): 289031186084 Duration of data (realtime) : 86400

(76)

flow-stat – Source AS %

Total

#

(77)

flow-stat – Dest AS % Total

#

(78)

flow-stat – Src/Dest AS %

Total

#

(79)

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.

(80)

flow-gen

• Debugging tool to generate flows.

eng1:% flow-gen -V8.1 | flow-print | head -10

srcAS dstAS in out flows octets packets duration

(81)

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

(82)

flow-receive

• Like flow-capture but does not

manage disk space. Output is to

standard out and can be used

directly with other flow-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

(83)

flow-import

• Import flows from other formats

into flow-tools.

(84)

flow-export

• Export flows from flow-tools files

to other formats.

• Currently supports ASCII and

cflowd formats.

(85)

flow-xlate

• Translate flows among NetFlow

versions.

• Originally intended for use with

(86)

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

(87)

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/ipfix-charter.html

Requirements for IP Flow Information Export (RFC

3917)

(88)

References

• flow-tools:

http://

www.splintered.net/sw/flow-tools

• NetFlow Applications

http://

www.inmon.com/technology/netflowapps.php

• Netflow HOW-TO

http://www.linuxgeek.org/netflow-howto.php

(89)

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]

(90)

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

(91)

Acknowledgements

References

Related documents

These include inadequate skip supply for storing waste; high population to skip ratio; lack of routine collection of waste, poor methods of waste management and inadequate

Version | Service | Total Length ID | Flags | Fragment TTL | Protocol | IP Checksum Source IP Address Destination IP Address IP Options Source UDP Port Destination

2 Library of the University of Silesia, Bankowa 11a, 40 007 Katowice, Poland; [email protected] 3 Institute of Culture Studies, The University of Silesia, pl. The study

Version | Service | Total Length ID | Flags | Fragment TTL | Protocol | IP Checksum Source IP Address Destination IP Address IP Options Source UDP Port Destination

From a NetFlow point of view, a flow is a unique combination of the source and destination IP addresses, source and destination TCP/UDP port numbers, IP protocol type, IP Type

The flow exporter part of the configuration examples defines an exporter (called “NetFlow-to-Orion”) the destination (the IP address of the Orion server) to which flow data will

Network Foundation Protection, 1/05 Interface Source IP address IP header TCP/UDP header Source port Data packet Destination port. NetFlow and

IETF: IP Flow Information Export IPFIX Working Group • IPFIX is an effort to: Define the notion of a “standard IP flow” Devise data encoding for IP flows Consider the notion of IP