Hi all,
In this post, I will show how to select
routes when the AS_Path attribute lengths of two BGP routes are the same but
the AS numbers are different.
First, let's draw a conclusion. After BGP load balancing is configured on a Huawei router, if the router receives two routes with the same AS_Path length but different AS numbers, load balancing cannot be implemented between the two routes because the AS_Path attributes of the two routes are different, Huawei routers do not select the optimal route based on the AS number in the AS_Path attribute. Instead, Huawei routers select the route with the smallest router ID based on the router ID of the neighbor. In V800R009, the load-balancing as-path-relax command is added. After this command is run, the two routes with the same AS_Path length but different AS numbers are used for load balancing.
Experiment topology
![]()
Key Configuration
RT01
interface Ethernet1/0/0
undo shutdown
ip address 10.1.2.1 255.255.255.252
interface Ethernet1/0/1
undo shutdown
ip address 10.1.3.1 255.255.255.252
bgp 100
router-id 1.1.1.1
peer 10.1.2.2 as-number 200
peer 10.1.3.2 as-number 300
ipv4-family unicast
undo synchronization
maximum load-balancing 8
peer 10.1.2.2 enable
peer 10.1.3.2 enable
RT02
interface Ethernet1/0/0
undo shutdown
ip address 10.1.2.2 255.255.255.252
bgp 200
router-id 2.2.2.2
peer 10.1.2.1 as-number 100
ipv4-family unicast
undo synchronization
network 192.168.1.0 255.255.255.0
peer 10.1.2.1 enable
ip route-static 192.168.1.0 255.255.255.0 NULL0
RT03
interface Ethernet1/0/1
undo shutdown
ip address 10.1.3.2 255.255.255.252
bgp 300
router-id 3.3.3.3
peer 10.1.3.1 as-number 100
ipv4-family unicast
undo synchronization
network 192.168.1.0 255.255.255.0
peer 10.1.3.1 enable
ip route-static 192.168.1.0 255.255.255.0 NULL0
Observation and verification
Check the routing table on RT01. You can find that the route 192.168.1.0/24 has only one next hop and does not implement load balancing, as shown in the following figure.
![]()
On RT01, check detailed information about the BGP route 192.168.1.0/24. The command output shows that router-id prefers the route sent by RT02, as shown in the following figure.
![]()
To verify that Huawei devices only compare router ID, but not the AS number. After the router ID of RT02 is changed to 4.4.4.4, RT01 prefers the route sent by RT03, as shown in the following figure.
![]()
After the load-balancing as-path-relaxcommand is run on RT01, the route 192.168.1.0/24 is used for load balancing, as shown in the following figure.
![]()
Summary
The BGP routes with the same AS_Path attribute can be used for load balancing. Note that the AS_Path attributes of the BGP routes with the same length and AS number must be the same. When the AS_Path attribute lengths of two BGP routes are the same but the AS numbers in the AS_Path attributes are different, the Huawei device does not select routes based on the AS number. That is, the Huawei device does not discriminate routes with a larger AS number. After all, in the BGP world, AS numbers are equal regardless of their sizes.