28.06.2014 Views

Discussion

Discussion

Discussion

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9.12 Using a Firewall Filter to Count Traffic<br />

on an Interface<br />

Problem<br />

You want to find out how much traffic is passing through an interface.<br />

Solution<br />

To check how much traffic is successfully passing through an interface, add the count<br />

option to a then clause that accepts traffic:<br />

[edit firewall filter incoming-to-me]<br />

aviva@RouterF# set term final-accept then count incoming-accepted<br />

aviva@RouterF# set term final-accept then accept<br />

To track unwanted traffic, use the count option and a then clause that discards traffic:<br />

[edit firewall filter incoming-to-me]<br />

aviva@RouterF# set term reject-addresses then count bad-addresses<br />

aviva@RouterF# set term final-accept then discard<br />

To look at the counters, use the show firewall filter command:<br />

aviva@RouterF> show firewall filter incoming-to-me<br />

Filter: incoming-to-me<br />

Counters:<br />

Name Bytes Packets<br />

incoming-accepted 246 4<br />

<strong>Discussion</strong><br />

Either as part of your standard network practices or while tracking a problem, you<br />

often want to know how much traffic has either successfully passed through an interface<br />

or how much traffic attempted but failed to pass through an interface. You do<br />

this by counting the packets that match each term in a firewall filter.<br />

The first command in this recipe counts all the traffic accepted by the interface other<br />

than the ICMP and BGP traffic. Each counter is identified by name, and this counter<br />

is called incoming-accepted.<br />

Use the show firewall filter command to see the counters. The output is very<br />

straightforward, showing how many bytes and packets have matched the finalaccept<br />

term in the filter.<br />

The second command in this recipe shows how to count unwanted traffic. As a general<br />

point, you rarely just reject a firewall term without also either counting the rejections<br />

or logging or syslogging it (see Recipe 9.13). Tracking the rejections is useful for<br />

documenting abuse of your router, attacks on the router, or even misconfigurations.<br />

Using a Firewall Filter to Count Traffic on an Interface | 315<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!