O'Reilly logo

JUNOS Cookbook by Aviva Garrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.8. Filtering BGP Routes Based on AS Paths

Problem

You want to filter the BGP routes that you send or receive based on the AS path information in the routes.

Solution

To filter the routes, create a routing policy that acts on a route's AS path information. The first step is to define a regular expression that matches the AS path information:

	[edit policy-options]
	aviva@RouterD#  
set as-path from-AS-65500 "65500{4}"

Then reference the AS path information in a routing policy:

	[edit policy-options policy-statement match-AS65500]
	aviva@RouterD# set term 1 from as-path from-AS-65500
	aviva@RouterD# set term 1 then reject
	aviva@RouterD# set term accept-others then accept

Finally, apply the policy to a BGP group:

	[edit protocols bgp]
	aviva@RouterD# set group session-to-AS65500 import match-AS65500

Discussion

It it often useful to develop routing policies based on information within the AS path information. You can then use these policies to enforce your network's administrative policy with respect to a customer or peer. Instead of looking for many prefixes or routes individually, it can be easier to use the AS path. The AS path attribute lets you filter all routes that originated from or transited through a particular AS, all routes announced by a particular neighboring AS, and routes that originated in the local AS.

To match information in the AS path attribute, you first create a regular expression that identifies the match conditions. In this recipe, the set as-path command creates the regular ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required