28.06.2014 Views

Discussion

Discussion

Discussion

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Then create a policy that references the list of prefixes:<br />

[edit policy options policy-statement addresses-to-reject]<br />

aviva@router1# set term 1 from prefix-list PREFIX-LIST-1<br />

aviva@router1# set term 1 then reject<br />

Finally, apply the policy to a protocol, here to EBGP:<br />

[edit protocols bgp]<br />

aviva@router1# set group external-group import addresses-to-reject<br />

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

One of the most common uses of routing policies is to filter routes based on the IP<br />

address prefix. You create a prefix list and then reference it in the from clause of a<br />

routing policy. Instead of looking at the protocol information in routes, the policy<br />

examines the route prefix itself. This provides you with fine-grained control for identifying<br />

routes that you want to act on. A prefix list is simply a list, so it contains no<br />

information about what actions to take. You can create various lists in the [edit<br />

policy-options] hierarchy and then reference them as needed in different routing<br />

policies and also in firewall filters.<br />

Prefix lists are a great way to reuse IP addresses in a JUNOS configuration. They are<br />

handy for keeping lists of all your customers or separate lists of customers to whom<br />

you apply the same routing policies. For firewall filters, prefix lists are handy for listing<br />

network servers, such as DNS, NTP, and RADIUS or TACACS+ servers, in a single<br />

place. They are also handy for keeping a single list of your BGP peers and SNMP<br />

systems. Because the lists are defined only once, they help restrict the number of<br />

places you have to change, add, or manipulate IP addresses for network management<br />

and other tasks. Both routing policies and firewall filters can reference the same<br />

prefix lists.<br />

This recipe creates a list of prefixes that are rejected when they are received from<br />

EBGP peers. They are prefixes BGP should never install in the routing table or<br />

advertise to its peers. As a first step, create a list of prefixes by creating a named prefix<br />

list in the [edit policy-options] hierarchy. In this recipe, the prefix list named<br />

PREFIX-LIST-1 has two prefixes.<br />

Then define a policy that references the prefix list and specifies the action to take<br />

when a match occurs. This recipe creates a policy named addresses-to-reject. The<br />

from clause references the prefix list, which consists of the prefixes to match. If the<br />

prefix in a received packet exactly matches one of the prefixes, the action in the then<br />

clause is taken. This behavior is similar to a logical OR operation and differs from<br />

how matching is done for routing information, where all the conditions in the from<br />

clause have to match before an action is taken (similar to a logical AND operation).<br />

With a prefix list, when the packet’s prefix matches one of the listed prefixes, the<br />

action in the then clause is taken. When the JUNOS software evaluates a prefix to see<br />

if it matches one in the list, it searches through the entire list for the longest prefix<br />

292 | Chapter 9: Routing Policy and Firewall Filters<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!