set as-path

To modify an autonomous system path (as-path) for BGP routes, use the set as-path command. To not modify the autonomous system (AS) path, use the no form of this command.

set as-path { tag | { prepend as-num [ ... as-num ] | last-as num }}

no as-path { tag | { prepend as-num [.. . as-num ] | last-as num }}

Syntax Description

tag
Converts the tag of a route into an autonomous system path. Applies only when redistributing routes into Border Gateway Protocol (BGP).
prepend as-num
Appends the specified AS number to the autonomous system path of the route that is matched by the route map. Applies to both inbound and outbound BGP route maps. Range: 1 to 65535. You can configure more than on AS number.
last-as num
Prepends the last AS numbers to the as-path. Range: 1 to 10.

Command Default

Autonomous system path is not modified.

Command Modes

Route-map configuration mode

Command History

Release
Modification
5.0(3)N1(1)
This command was introduced.

Usage Guidelines

Once you enter route-map configuration mode, you can enter the set command.

The only global BGP metric available to influence the best path selection is the autonomous system path length. By varying the length of the autonomous system path, a BGP speaker can influence the best-path selection by a peer further away.

By allowing you to convert the tag into an autonomous system path, the set as-path tag variation of this command modifies the autonomous system length. The set as-path prepend variation allows you to prepend an arbitrary autonomous system path string to BGP routes. Usually, the local autonomous system number is prepended multiple times, increasing the autonomous system path length.

Examples

This example shows how to convert the tag of a redistributed route into an autonomous system path:

switch(config)# route-map test1
switch(config-route-map)# set as-path tag
 

This example shows how to prepend 100 to all the routes advertised to 10.108.1.1:

switch(config)# route-map test1
switch(config-route-map)# match as-path 1
switch(config-route-map)# set as-path prepend 100
 
 
switch(config)# router bgp 64496
switch(config-router)# neighbor 10.108.1.1 remote-as 64497
switch(config-router-neighbor)# address-family ipv4 unicast
switch(config-router-neighbor-af)# route-map set-as-path test1 out
 

Related Commands

Command
Description
match as-path
Matches a BGP autonomous system path access list.
route-map (IP)
Defines the conditions for redistributing routes from one routing protocol into another.