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