set as-path
To modify an autonomous system path (as-path) for Border Gateway Protocol (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 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. The range is from 1 to 65535. You can configure more than one AS number. |
last-as num |
Prepends the last AS numbers to the AS path. The range is from 1 to 10. |
Command Default
The Autonomous system path is not modified.
Command Modes
Route-map configuration (config-route-map)
Command History
Release |
Modification |
---|---|
4.0(1) |
This command was introduced. |
Usage Guidelines
You must enter the feature pbr command to enable policy-based routing (PBR) before entering the route-map command.
Use the route-map command to enter route-map configuration mode. Once you enter the route-map command, the prompt changes to the following:
switch(config-route-map)#
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 which increasing the autonomous system path length.
Examples
This example shows how to converts 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