Track1Agenda: exercise3-nfsen-top-talkers.page

File exercise3-nfsen-top-talkers.page, 8.1 KB (added by b.candler, 6 years ago)
Line 
1% Using NfSen to identify top talkers
2%
3% Network Monitoring and Management
4
5# Introduction
6
7## Goals
8
9* Use NfSen to find out which hosts are generating the most inbound
10  and outbound traffic on your network
11
12## Assumptions
13
14Your router is sending netflow records to one of your PCs, and that PC
15is running nfsen to collect this data. If you are working in a pair, then
16you should both point your web browser to whichever PC is receiving the
17flows:
18
19<http://pcX.ws.nsrc.org/nfsen/nfsen.php>
20
21# Generate some traffic
22
23Firstly, we need to generate some traffic passing through your router.
24On either of your PCs (it doesn't have to be the one running nfsen), login
25and type the following commands:
26
27~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28$ cd /tmp
29$ wget http://noc.ws.nsrc.org/downloads/BigFile
30$ rm BigFile
31~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
33It will take around 5 minutes before this shows as a spike in nfsen.
34
35# Exploring flow records
36
37Now let's use Netflow to explore the traffic flows in the network, with the
38aim of finding out who was been downloading the most data.  Look carefully
39at the output generated at each step - ask an instructor to explain if you
40don't understand what you see.
41
42## Navigate to Detail page
43
44The nfsen home page shows a matrix of graphs: flows per second on the left,
45packets per second in the middle, bits per second on the right.  Click on
46the top-right graph (bits per second, one day view) to get to the Detail
47page.
48
49## Select time window
50
51Change from "Single Timeslot" to "Time Window":
52
53![Selecting time window](images/nf-time-window.png)\
54
55Once you have done this, the vertical line in the graph window can be split.
56Pull the left half to the left and the right half to the right, to select
57the time period of interest. Then you should see some summary statistics
58for the time period you have selected:
59
60![Summary statistics](images/nf-statistics.png)
61
62## List individual flows
63
64Select "List Flows", make sure all the Aggregate boxes are not checked, and
65then click `process`.  This will display some flows at the beginning of the
66time period.
67
68![List flows](images/nf-list-flows.png)
69
70Increase the limit from 20 flows to 100 flows. Notice that much network
71traffic consists of large numbers of very small flows - for example a DNS
72query/response will be two flows, one from client to DNS server, and one
73back again.
74
75By selecting "bi-directional" you can get nfsen to associate the inbound and
76outbound flows into a single line:
77
78![Bi-directional flows](images/nf-bidirectional.png)
79
80However it's still too much work to wade through this looking for
81interesting traffic. Uncheck the "Bi-directional" box before continuing.
82
83## Flows to/from one host
84
85If we know which host we want to examine, we can apply a filter to show only
86those flows to and from that host.  Do this by entering "host 10.10.X.Y" in
87the filter box, and then pressing `process` again.  (Replace 10.10.X.Y with
88the address of one of your PCs)
89
90![Flows to and from one host](images/nf-flows-host.png)
91
92This is a little better, but we would still have to wade through lots of
93small flows to find anything significant.  We need to take a different
94approach.
95
96# Largest flows
97
98The next thing we can do is to get nfsen to sort the flows by number of
99bytes.  Remove any filter from the Filter box; select "Stat TopN", stat "Flow
100Records", order by "Bytes".  Ensure all the aggregate boxes are all unchecked,
101then press `process`
102
103![Find top flows by bytes](images/nf-topn-bytes.png)
104
105![Output: top flows by bytes](images/nf-topn-bytes-output.png)
106
107This is a definite improvement, as the flows with the largest number of
108bytes are shown first.  However there's a problem - we are still looking at
109individual flows.  It's possible that many small flows to the same host
110would add up to a large amount of traffic, but we wouldn't see them at the
111top of this list.
112
113# Inbound traffic grouped by receiver IP address
114
115What we want to see is a single line for each host in our network, showing
116the total amount of traffic delivered to that host.
117
118To do this, Stat "DST IP Address", order by "bytes".
119
120![Group flows by DST IP Address](images/nf-topn-dest.png)
121
122This is now much closer to what we want: there is one line for each
123destination IP address, and they are ordered by total bytes, largest first.
124
125But there is still one problem - can you see what it is? We are seeing a
126mixture of inbound flows (where the destination IP is inside our network)
127and outbound flows (where the destination IP is on the Internet).  We are
128only interested in the inbound flows, so apply a filter which shows only
129traffic to your group's network: "dst net 10.10.X.0/24" (replacing X with
130your group number)
131
132![Flows to local network, grouped by DST IP Address](images/nf-topn-dst-local.png)
133
134![Output: Flows to local network, grouped by DST IP Address](images/nf-topn-dst-local-output.png)
135
136At last we have what we want.  The first record you see should tell you the
137local machine which has downloaded the most traffic in the period selected.
138
139## Outbound traffic grouped by sender IP address
140
141Question: what changes would you have to make to this query to find out
142which machines in your network are _uploading_ the most traffic to the
143Internet?
144
145# Analysing traffic to a single host
146
147Now that we know which host has downloaded the most traffic, we might want
148to see where it has been downloading from.
149
150Let's start by looking at the top flows to that host. Change the filter to
151"dst host 10.10.X.Y" (the IP address you just found).  Then select Stat
152"Flow Records", order by "bytes", and `process`.
153
154![Largest flows to one host](images/nf-dst-host-flows.png)
155
156You should now see the flows inbound to that host, largest first. But again,
157we're only seeing large individual flows; a collection of small flows may
158add together to a large amount of traffic.
159
160Since we are only looking at flow records to one particular destination IP
161address, we can group these records by source IP address.
162
163![Flows to one host, grouped by SRC IP address](images/nf-dst-host-srcs.png)
164
165![Output: Flows to one host, grouped by SRC IP address](images/nf-dst-host-srcs-output.png)
166
167And now we have one row for each IP address this host has been downloading
168from, with the total number of bytes downloaded from each IP, largest total
169first.
170
171## IP address information
172
173By clicking on an IP address, you will get some information from reverse DNS
174and whois.
175
176![Whois information](images/nf-whois.png)
177
178# Additional exercise: aggregating flows
179
180nfsen offers some other ways to summarise the flows, using the Aggregate
181checkboxes.  In this example we'll look again at traffic inbound to your
182network.
183
184When you click one or more of the Aggregate boxes, nfsen combines all flows
185that share the same values of the attribute(s) you have selected.
186
187To start this exercise, set the filter to "dst net 10.10.X.0/24" (X = your
188group).  Select "Stat TopN", Stat "Flow Records", order by "bytes".  Then
189try the following aggregates, remembering to click `process` after each one.
190
191* Check "proto". You should get just one row each for TCP, UDP and ICMP,
192showing the total amount of traffic using each protocol.  Sometimes this may
193show other protocols are active on your network (e.g.  protocol 50 = IPSEC
194ESP; in Linux the file `/etc/protocols` has a list of them)
195
196* Check both "proto" and "srcPort". This tells nfsen to combine together
197flows which have the same proto *and* the same srcPort.  Depending on what
198activity has been going on, you may see one line giving the total for TCP
199port 80, one line for TCP port 443, one line for UDP port 53, and so on.
200
201* Check "srcIP" by itself. This gives one row for each distinct source IP
202address, and is the same as selecting Stat SRC IP.
203
204* Check both "srcIP" and "dstIP". You will get one row for each unique pair
205of srcIP and dstIP seen, with the total traffic between those two endpoints.
206
207How would you change the filter to look at outbound traffic, rather than
208inbound traffic?
209
210If you have a router with a full BGP table, you can aggregate netflow
211records by AS number.  This is a useful way to find out what networks you
212are exchanging the most traffic with.