Prepending AS Numbers to the AS Path

Table of contents:

Problem

You want to extend the number of values in the AS path to make that path appear to be less preferable.

Solution

In the JUNOS software, you prepend paths to the AS path using routing policy. First, create a policy the defines the AS path string to prepend:

	[edit policy-options]
	aviva@RouterF# set policy-statement prepend-as-path then prepend-as-path "65500 65500
	65500"

Then, apply the policy to the EBGP group:

	[edit bgp]
	aviva@RouterF# set group session-to-AS65505 export prepend-as-path

Discussion

When ASs have multiple connections between them, you might want to make the remote AS prefer one of those paths when it is sending traffic to your AS. An easy way to force external routers to choose a particular path is to adjust the AS path attribute. Early on in the process of determining the active route to a destination (see the Introduction to Chapter 8), a BGP router looks at the AS path and chooses the prefix with the shorter path. If you lengthen the path for routes that use a particular EBGP connection, the remote network will reach you using a different connection. There still might be times when the route with the lengthened AS path is used because it is the shorter path, so you can prepend the same AS number several times to lengthen the path even more.

This recipe prepends the local AS number to BGP prefixes exported on this BGP connection. To do this, you create a routing policy. Because you want the policy to match all BGP prefixes, you don need a from clause. If you want to prepend the AS numbers only to certain prefixes, list them in a from clause. Then apply the policy to the EBGP group.

Looking at the remote AS before applying this policy, you see that the AS path for each prefix in AS 65500 lists the AS only once:

	aviva@RouterD> show route protocol bgp
	inet.0: 19 destinations, 25 routes (19 active, 0 holddown, 0 hidden)
	+ = Active Route, - = Last Active, * = Both
	0.0.0.0/0 [BGP/170] 00:00:13, localpref 100
	 AS path: 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	10.0.8.0/24 *[BGP/170] 00:00:13, localpref 100
	 AS path: 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	10.0.13.0/24 *[BGP/170] 00:00:13, localpref 100
	  
AS path: 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	10.0.31.0/24 [BGP/170] 00:00:13, localpref 100
	 AS path: 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	172.19.121.0/24 [BGP/170] 00:00:13, localpref 100
	 AS path: 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	192.168.15.1/32 *[BGP/170] 00:00:13, MED 65, localpref 100
	 AS path: 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	192.168.16.1/32 *[BGP/170] 00:00:13, localpref 100
	 AS path: 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	192.168.17.1/32 *[BGP/170] 00:00:13, MED 1, localpref 100
	 AS path: 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0

After the policy is applied, you see the lengthened AS paths for these prefixes:

	aviva@RouterD> show route protocol bgp
	inet.0: 19 destinations, 25 routes (19 active, 0 holddown, 0 hidden)
	+ = Active Route, - = Last Active, * = Both
	0.0.0.0/0 [BGP/170] 00:01:06, localpref 100
	 AS path: 65500 65500 65500 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	10.0.8.0/24 *[BGP/170] 00:01:06, localpref 100
	 AS path: 65500 65500 65500 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	10.0.13.0/24 *[BGP/170] 00:01:06, localpref 100
	 AS path: 65500 65500 65500 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	10.0.31.0/24 [BGP/170] 00:01:06, localpref 100
	 AS path: 65500 65500 65500 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	172.19.121.0/24 [BGP/170] 00:01:06, localpref 100
	 AS path: 65500 65500 65500 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	192.168.15.1/32 *[BGP/170] 00:01:06, MED 65, localpref 100
	 AS path: 65500 65500 65500 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	192.168.16.1/32 *[BGP/170] 00:01:06, localpref 100
	 AS path: 65500 65500 65500 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0
	192.168.17.1/32 *[BGP/170] 00:01:06, MED 1, localpref 100
	 AS path: 65500 65500 65500 65500 I
	 > to 10.0.31.2 via t1-0/0/3.0


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