The AS_Path attribute records all of the ASs that a route passes through from the source to the destination in the vector order. You can configure the AS_Path attribute to implement flexible route selection.
Generally, BGP compares the AS_Path lists of routes and prefers the route with the shortest AS_Path list. When the AS_Path attribute is not required in route selection, configure BGP not to compare the AS_Path lists of routes during route selection.
In most cases, BGP detects routing loops based on the AS number. However, to ensure correct route transmission on a hub-and-spoke network, you need to configure all the BGP peers that VPN routes advertised from a hub CE to a spoke CE pass through to accept the routes with a repeated AS number.
Public AS numbers can be used on the Internet, but not private AS numbers because they may cause routing loops. To prevent routing loops, configure the AS_Path attribute to carry only public AS numbers in EBGP Update messages.
When the AS_Path attribute is reconstructed or summarized routes are generated, you can set the maximum number of AS numbers in the AS_Path attribute. Then a BGP device checks whether the number of AS numbers in the AS_Path attribute of a route exceeds the maximum value. If so, the BGP device discards the route.
A device usually supports only one BGP process. This indicates that a device supports only one AS number. In some cases, for example, when network migration changes an AS number, you can set a fake AS number to ensure successful network migration.
BGP checks the first AS number in the AS_Path list that is carried in the Update message sent by an EBGP peer. If the first AS number specifies the AS where the EBGP peer resides, BGP accepts the Update message. Otherwise, BGP rejects the Update message and interrupts the EBGP connection. If you do not want BGP to check the first AS number, disable the option.
The system view is displayed.
A node is configured for a route-policy, and the view of the route-policy is displayed.
By default, all routes meet matching rules. For details, see (Optional) Configuring an if-match Clause.
The AS_Path attribute is set for BGP routes.
Return to the system view.
The BGP view is displayed.
Run ipv4-family { unicast | multicast }
The IPv4 address family view is displayed.
Run ipv6-family [ unicast ]
The IPv6 address family view is displayed.
The AS_Path attribute is added to the routes advertised to BGP peers or peer groups.
The AS_Path attribute is added to the routes received from BGP peers or peer groups.
The AS_Path attribute is added to the routes imported by BGP in import mode.
The AS_Path attribute is added to the routes imported by BGP in network mode.
Run bestroute as-path-ignore
BGP is configured not to compare the AS_Path attributes of routes during route selection.
By default, BGP compares the AS_Path attributes of routes during route selection.
Run peer { ipv4-address | group-name | ipv6-address } allow-as-loop [ number ]
Repeated local AS numbers are allowed in routes.
By default, repeated local AS numbers are not allowed.
Run peer { ipv4-address | group-name | ipv6-address } public-as-only [ force ]
BGP is configured to carry only public AS numbers in the AS_Path attribute in an EBGP Update message.
By default, the AS_Path attribute can carry both public and private AS numbers in an EBGP Update message.
Return to the BGP view.
Run as-path-limit as-path-limit-num
The maximum number of AS numbers in the AS_Path attribute is set.
By default, the maximum number of AS numbers in the AS_Path attribute is 255.
Run peer { ipv4-address | group-name | ipv6-address } fake-as [ prepend-global-as ]
The peer fake-as command can be used to hide the actual AS number of a BGP device. EBGP peers in other ASs will use the fake AS number of this BGP device to set up EBGP peer relationships with this device.
A fake AS number is configured for an EBGP peer group.
By default, EBGP peers establish a connection using the actual AS number.
Running the undo check-first-as command increases the probability of routing loops. Therefore, exercise caution when using this command.
Run undo check-first-as
BGP is configured not to check the first AS number in the AS_Path list that is carried in the Update message sent by an EBGP peer.
By default, BGP checks the first AS number in the AS_Path list that is carried in the Update message sent by an EBGP peer.
When BGP is disabled from checking the first AS number, run the refresh bgp command in the user view if you want BGP to check the first AS number of received routes.