Adjusting Local Preference Values

Problem

You want to change the value of the BGP local preference attribute to control which routes the router uses.

Solution

There are two ways to change the local preference value. The first method changes the value for all routes distributed into IBGP from the router:

	[edit protocols bgp]
	aviva@RouterF# set group internal-within-AS65500 local-preference 140

The second method allows you to change the preference of specific routes:

	[edit policy-options policy-statement set-local-pref ]
	aviva@RouterF# set from route-filter 192.168.14.1/32 exact 
	aviva@RouterF# set then local-preference 140 
	aviva@RouterF# set then accept 

	[edit protocols bgp group session-to-AS65505 ]
	aviva@RouterF# set import set-local-pref 

Discussion

When IBGP routers exchange prefix information, one of the attributes associated with each prefix is its local preference ( LOCAL_PREF) value. This attribute is not advertised to EBGP peers. IBGP routers use the local preference value as a metric to decide which routes should exit the AS, choosing the route with the highest local preference value. The default local preference value is 100. BGP includes the local preference value only when advertising prefixes to IBGP peers. It is not advertised to EBGP peers.

When the router is determining the active route to a destination (see the Introduction to Chapter 8), one of the first things it considers is the BGP local preference, so changing the local preference is a useful way to manipulate route selection. By selecting from multiple routes to a destination, the local preference is the first BGP path attribute checked, even before the AS path length, the origin, and the MED.

Don confuse the BGP local preference with the JUNOS software routing-protocol preference (see Table 8-2). The JUNOS routing preference is local to each router, and the software uses it to choose the active route when there are a number of paths to the same prefix. The BGP local preference is used only by BGP, and only by IBGP routers within an AS. Also, the choice is between two different types of preference values that are the reverse of each other. For the JUNOS routing-protocol preference, the route with the lowest value is chosen, but with the BGP local preference, the route with the highest value is chosen.

The first configuration in this recipe changes the local preference for all routes in the IBGP group to 140, making them more preferred over unaltered routes, which have a default local preference of 100. The second configuration creates a routing policy that changes the local preference value just on the one route, 192.168.14.1/32. Another variation of this policy is to change the value on all routes coming from a particular AS:

	[edit policy-options]
	aviva@RouterF# set as-path local-pref-path "65505 .*"
	aviva@RouterF# set policy-statement AS-local-pref from as-path local-pref-path
	aviva@RouterF# set policy-statement AS-local-pref then local-preference 140
	aviva@RouterF# set policy-statement AS-local-pref then accept

This policy modifies the preference only for routes that have 65505 as the first AS in the AS path. No other BGP routes are affected by this routing policy.

Looking again at the original policy in this recipe, before applying the policy, the route has the default local preference of 100:

	[edit policy-options]
	aviva@RouterF> show route 192.168.14.1/32
	inet.0: 24 destinations, 28 routes (24 active, 0 holddown, 0 hidden)
	+ = Active Route, - = Last Active, * = Both
	192.168.14.1/32 *[BGP/170] 00:05:48, localpref 100
	 AS path: 65505 I
	 > to 10.0.31.1 via t1-0/0/3.0

After applying the policy, the local preference changes to 140:

	aviva@RouterF> show route 192.168.14.1/32
	inet.0: 24 destinations, 28 routes (24 active, 0 holddown, 0 hidden)
	+ = Active Route, - = Last Active, * = Both
	192.168.14.1/32 *[BGP/170] 00:08:15, localpref 140
	 AS path: 65505 I
	 > to 10.0.31.1 via t1-0/0/3.0

See Also

The Introduction to Chapter 8


Router Configuration and File Management

Basic Router Security and Access Control

IPSec

SNMP

Logging

NTP

Router Interfaces

IP Routing

Routing Policy and Firewall Filters

RIP

IS-IS

OSPF

BGP

MPLS

VPNs

IP Multicast



JUNOS Cookbook
Junos Cookbook (Cookbooks (OReilly))
ISBN: 0596100140
EAN: 2147483647
Year: 2007
Pages: 290
Authors: Aviva Garrett

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net