The AS_Path attribute records all the ASs that a route passes through from the source to the destination in the vector order. To prevent inter-AS routing loops, a BGP device does not receive the routes of which the AS_Path list contains the local AS number.
When a BGP speaker advertises an imported route:
If the route is advertised to EBGP peers, the BGP speaker creates an AS_Path list containing the local AS number in an Update message.
If the route is advertised to IBGP peers, the BGP speaker creates an empty AS_Path list in an Update message.
When a BGP speaker advertises a route learned in the Update message sent by another BGP speaker:
If the route is advertised to EBGP peers, the BGP speaker adds the local AS number to the leftmost of the AS_Path list. According to the AS_Path list, the BGP speaker that receives the route can learn about the ASs through which the route passes to reach the destination. The number of the AS that is nearest to the local AS is placed on the top of the AS_Path list. The other AS numbers are listed according to the sequence in which the route passes through ASs.
If the route is advertised to IBGP peers, the BGP speaker does not change the AS_Path attribute of the route.
You can configure the AS_Path attribute to implement flexible route selection.
Apply a Routing Policy to Routes Advertised
The set protocols bgp neighbor route-map command applies a route map to incoming or outgoing routes. It can be used to configure the route map for modifying the AS_Path attribute of the route.
Configure an AS Path List to Advertise or Receive Routes from Peers
The set protocols bgp neighbor filter-list command configures an AS Path list to advertise or receive routes from peers.
Configure BGP to Treat two BGP Routes as Equal Cost ven if AS-paths Differ
he set protocols bgp bestpath as-path multipath-relax command configures Border Gateway Protocol (BGP) to treat two BGP routes as equal cost even if their AS-paths differ, as long as their AS-path lengths and other relevant attributes are the same. This allows routes with different AS-paths to be programmed into the forwarding table as equal cost multipath routes. Any changes in BGP configuration are applied by restarting the current BGP sessions on the VRFs.