Bestpath
Scenario to verify BGP bestpath parameter configuration.
The bestpath parameters control how BGP selects the best route when multiple
paths exist to the same destination. This test suite verifies the following
sub-commands: as-path ignore and compare-routerid.
DUT0 (AS 100) receives the same route from two eBGP neighbors (DUT1 and DUT2) with different attributes. The tests demonstrate how each bestpath parameter changes the route selection behavior.
Test eBGP - Bestpath as-path ignore changes route selection
Description
Test that bestpath as-path ignore causes BGP to ignore AS-path length
when selecting the best route. DUT0 (AS 100) receives route
192.168.10.0/24 from DUT1 (AS 200, MED 100, AS-path length 1) and
DUT2 (AS 200, MED 50, AS-path length 2). Without the parameter, the
shorter AS-path wins. With the parameter, AS-path is ignored and MED
determines the selection.
Scenario
Note
DUT1 has shorter AS-path (length 1) with MED 100. DUT2 has longer AS-path (length 2, prepend) with MED 50.
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.10.0.100/24 set interfaces ethernet eth1 address 20.20.0.100/24 set protocols bgp 100 neighbor peer1 remote-address 10.10.0.200 set protocols bgp 100 neighbor peer1 remote-as 200 set protocols bgp 100 neighbor peer1 route-map import PERMIT set protocols bgp 100 neighbor peer2 remote-address 20.20.0.201 set protocols bgp 100 neighbor peer2 remote-as 200 set protocols bgp 100 neighbor peer2 route-map import PERMIT set protocols route-map PERMIT rule 1 action permit set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 2: Set the following configuration in DUT1 :
set interfaces dummy dum0 address 192.168.10.1/24 set interfaces ethernet eth0 address 10.10.0.200/24 set protocols bgp 200 neighbor peer remote-address 10.10.0.100 set protocols bgp 200 neighbor peer remote-as 100 set protocols bgp 200 neighbor peer route-map export SET-MED set protocols bgp 200 redistribute connected route-map SET-MED set protocols route-map SET-MED rule 1 action permit set protocols route-map SET-MED rule 1 set metric 100 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Set the following configuration in DUT2 :
set interfaces dummy dum0 address 192.168.10.1/24 set interfaces ethernet eth1 address 20.20.0.201/24 set protocols bgp 200 neighbor peer remote-address 20.20.0.100 set protocols bgp 200 neighbor peer remote-as 100 set protocols bgp 200 neighbor peer route-map export SET-MED-PREPEND set protocols bgp 200 redistribute connected route-map SET-MED-PREPEND set protocols route-map SET-MED-PREPEND rule 1 action permit set protocols route-map SET-MED-PREPEND rule 1 set as-path prepend 200 set protocols route-map SET-MED-PREPEND rule 1 set metric 50 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Attention
Verify both eBGP sessions establish between DUT0 and its neighbors.
Step 4: Run command protocols bgp show ip summary at DUT0 and check if output matches the following regular expressions:
10.10.0.200.*Established[\s\S]+20.20.0.201.*EstablishedShow output
IPv4 Unicast Summary: BGP router identifier 20.20.0.100, local AS number 100 VRF default vrf-id 0 BGP table version 2 RIB entries 3, using 384 bytes of memory Peers 2, using 47 KiB of memory Neighbor LocalAddr V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State PfxRcd PfxSnt Desc 10.10.0.200 10.10.0.100 4 200 5 5 2 0 0 00:00:07 Established 2 (Policy) N/A 20.20.0.201 20.20.0.100 4 200 2 2 0 0 0 00:00:00 Established 0 (Policy) N/A Total number of neighbors 2
Attention
Verify DUT0 receives route from both neighbors.
Step 5: Run command protocols bgp show ip at DUT0 and check if output matches the following regular expressions:
192.168.10.0/24[\s\S]+(10.10.0.200[\s\S]+20.20.0.201|20.20.0.201[\s\S]+10.10.0.200)Show output
BGP table version is 3, local router ID is 20.20.0.100, vrf id 0 Default local pref 100, local AS 100 local address - Status codes: s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *u 10.10.0.0/24 10.10.0.200 100 0 200 ? *u 20.20.0.0/24 20.20.0.201 50 0 200 200 200 ? *u 192.168.10.0/24 20.20.0.201 50 0 200 200 200 ? *u 10.10.0.200 100 0 200 ? Displayed 3 routes and 4 total paths
Note
Without as-path ignore, DUT0 selects DUT1 route because AS-path is shorter (1 vs 2).
Step 6: Run command protocols bgp show ip 192.168.10.0/24 at DUT0 and check if output matches the following regular expressions:
10.10.0.200[\s\S]+best \(AS Path\)Show output
BGP routing table entry for 192.168.10.0/24, version 2 Paths: (2 available, best #2, table default) Not advertised to any peer 200 200 200 20.20.0.201 from 20.20.0.201 (192.168.10.1) Origin incomplete, metric 50, valid, external Last update: Thu Mar 5 14:58:18 2026 200 10.10.0.200 from 10.10.0.200 (192.168.10.1) Origin incomplete, metric 100, valid, external, best (AS Path) Last update: Thu Mar 5 14:58:11 2026
Note
Enable as-path ignore to make BGP skip AS-path length comparison.
Step 7: Modify the following configuration lines in DUT0 :
set protocols bgp 100 parameters bestpath as-path ignore
Attention
Verify eBGP sessions remain established after configuration change.
Step 8: Run command protocols bgp show ip summary at DUT0 and check if output matches the following regular expressions:
10.10.0.200.*Established[\s\S]+20.20.0.201.*EstablishedShow output
IPv4 Unicast Summary: BGP router identifier 20.20.0.100, local AS number 100 VRF default vrf-id 0 BGP table version 4 RIB entries 5, using 640 bytes of memory Peers 2, using 47 KiB of memory Neighbor LocalAddr V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State PfxRcd PfxSnt Desc 10.10.0.200 10.10.0.100 4 200 5 5 4 0 0 00:00:10 Established 2 (Policy) N/A 20.20.0.201 20.20.0.100 4 200 5 3 4 0 0 00:00:03 Established 2 (Policy) N/A Total number of neighbors 2
Attention
Verify DUT0 now selects DUT2 route (MED 50 < MED 100) because AS-path is ignored.
Step 9: Run command protocols bgp show ip 192.168.10.0/24 at DUT0 and check if output matches the following regular expressions:
20.20.0.201[\s\S]+metric 50[\s\S]+best \(MED\)Show output
BGP routing table entry for 192.168.10.0/24, version 4 Paths: (2 available, best #1, table default) Not advertised to any peer 200 200 200 20.20.0.201 from 20.20.0.201 (192.168.10.1) Origin incomplete, metric 50, valid, external, best (MED) Last update: Thu Mar 5 14:58:18 2026 200 10.10.0.200 from 10.10.0.200 (192.168.10.1) Origin incomplete, metric 100, valid, external Last update: Thu Mar 5 14:58:11 2026
Test eBGP - Bestpath compare-routerid enables deterministic selection
Description
Test that bestpath compare-routerid uses router-id as a deterministic
tie-breaker for identical eBGP paths. DUT0 (AS 100) receives route
192.168.10.0/24 from DUT1 (AS 200, router-id 10.255.255.100) and
DUT2 (AS 200, router-id 10.255.255.50). Without the parameter, the
older path wins. With the parameter, the lower router-id wins.
Scenario
Note
DUT1 has higher router-id (10.255.255.100) and establishes first. DUT2 has lower router-id (10.255.255.50).
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.10.0.100/24 set interfaces ethernet eth1 address 20.20.0.100/24 set protocols bgp 100 neighbor peer1 remote-address 10.10.0.200 set protocols bgp 100 neighbor peer1 remote-as 200 set protocols bgp 100 neighbor peer1 route-map import PERMIT set protocols bgp 100 neighbor peer2 remote-address 20.20.0.201 set protocols bgp 100 neighbor peer2 remote-as 200 set protocols bgp 100 neighbor peer2 route-map import PERMIT set protocols route-map PERMIT rule 1 action permit set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 2: Set the following configuration in DUT1 :
set interfaces dummy dum0 address 192.168.10.1/24 set interfaces ethernet eth0 address 10.10.0.200/24 set protocols bgp 200 neighbor peer remote-address 10.10.0.100 set protocols bgp 200 neighbor peer remote-as 100 set protocols bgp 200 neighbor peer route-map export PERMIT set protocols bgp 200 parameters router-id 10.255.255.100 set protocols bgp 200 redistribute connected route-map PERMIT set protocols route-map PERMIT rule 1 action permit set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Set the following configuration in DUT2 :
set interfaces dummy dum0 address 192.168.10.1/24 set interfaces ethernet eth1 address 20.20.0.201/24 set protocols bgp 200 neighbor peer remote-address 20.20.0.100 set protocols bgp 200 neighbor peer remote-as 100 set protocols bgp 200 neighbor peer route-map export PERMIT set protocols bgp 200 parameters router-id 10.255.255.50 set protocols bgp 200 redistribute connected route-map PERMIT set protocols route-map PERMIT rule 1 action permit set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Attention
Verify both eBGP sessions establish between DUT0 and its neighbors.
Step 4: Run command protocols bgp show ip summary at DUT0 and check if output matches the following regular expressions:
10.10.0.200.*Established[\s\S]+20.20.0.201.*EstablishedShow output
IPv4 Unicast Summary: BGP router identifier 20.20.0.100, local AS number 100 VRF default vrf-id 0 BGP table version 2 RIB entries 3, using 384 bytes of memory Peers 2, using 47 KiB of memory Neighbor LocalAddr V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State PfxRcd PfxSnt Desc 10.10.0.200 10.10.0.100 4 200 5 3 2 0 0 00:00:07 Established 2 (Policy) N/A 20.20.0.201 20.20.0.100 4 200 2 2 0 0 0 00:00:01 Established 0 (Policy) N/A Total number of neighbors 2
Attention
Verify DUT0 receives route from both neighbors.
Step 5: Run command protocols bgp show ip at DUT0 and check if output matches the following regular expressions:
192.168.10.0/24[\s\S]+(10.10.0.200[\s\S]+20.20.0.201|20.20.0.201[\s\S]+10.10.0.200)Show output
BGP table version is 28, local router ID is 20.20.0.100, vrf id 0 Default local pref 100, local AS 100 local address - Status codes: s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *u 10.10.0.0/24 10.10.0.200 0 0 200 ? *u 20.20.0.0/24 20.20.0.201 0 0 200 ? *u 192.168.10.0/24 20.20.0.201 0 0 200 ? *u 10.10.0.200 0 0 200 ? Displayed 3 routes and 4 total paths
Note
Without compare-routerid, DUT0 selects DUT1 route because it is the older path.
Step 6: Run command protocols bgp show ip 192.168.10.0/24 at DUT0 and check if output matches the following regular expressions:
10.10.0.200[\s\S]+best \(Older Path\)Show output
BGP routing table entry for 192.168.10.0/24, version 30 Paths: (2 available, best #1, table default) Not advertised to any peer 200 10.10.0.200 from 10.10.0.200 (10.255.255.100) Origin incomplete, metric 0, valid, external, multipath, best (Older Path) Last update: Thu Mar 5 14:58:31 2026 200 20.20.0.201 from 20.20.0.201 (10.255.255.50) Origin incomplete, metric 0, valid, external, multipath Last update: Thu Mar 5 14:58:37 2026
Note
Enable compare-routerid to use router-id as deterministic tie-breaker.
Step 7: Modify the following configuration lines in DUT0 :
set protocols bgp 100 parameters bestpath compare-routerid
Attention
Verify eBGP sessions remain established after configuration change.
Step 8: Run command protocols bgp show ip summary at DUT0 and check if output matches the following regular expressions:
10.10.0.200.*Established[\s\S]+20.20.0.201.*EstablishedShow output
IPv4 Unicast Summary: BGP router identifier 20.20.0.100, local AS number 100 VRF default vrf-id 0 BGP table version 40 RIB entries 5, using 640 bytes of memory Peers 2, using 47 KiB of memory Neighbor LocalAddr V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State PfxRcd PfxSnt Desc 10.10.0.200 10.10.0.100 4 200 5 3 40 0 0 00:00:09 Established 2 (Policy) N/A 20.20.0.201 20.20.0.100 4 200 5 3 40 0 0 00:00:03 Established 2 (Policy) N/A Total number of neighbors 2
Attention
Verify DUT0 now selects DUT2 route (lower router-id: 10.255.255.50 < 10.255.255.100).
Step 9: Run command protocols bgp show ip 192.168.10.0/24 at DUT0 and check if output matches the following regular expressions:
20.20.0.201[\s\S]+best \(Router ID\)Show output
BGP routing table entry for 192.168.10.0/24, version 41 Paths: (2 available, best #1, table default) Not advertised to any peer 200 20.20.0.201 from 20.20.0.201 (10.255.255.50) Origin incomplete, metric 0, valid, external, multipath, best (Router ID) Last update: Thu Mar 5 14:58:37 2026 200 10.10.0.200 from 10.10.0.200 (10.255.255.100) Origin incomplete, metric 0, valid, external, multipath Last update: Thu Mar 5 14:58:31 2026