4 mins read

BGP – basic multipath

1. Intro

BGP typically selects only one best path for each prefix and installs that route in the forwarding table. When BGP multipath is enabled, the device selects multiple equal-cost BGP paths to reach a given destination, and all these paths are installed in the forwarding table. BGP advertises only the active path to its neighbors, unless add-path is in use.

A path is considered a BGP equal-cost path (and is used for forwarding) if the BGP path selection process performs a tie-break after comparing the IGP cost to the next-hop. By default, all paths with the same neighboring AS, learned by a multipath-enabled BGP neighbor are considered in the multipath selection process.

2. BGP Multipath configuration

The Initial config:

### R1 initial config: 

set protocols bgp group AS-200 peer-as 200
set protocols bgp group AS-200 neighbor 17.8.0.2
set protocols bgp group AS-300 peer-as 300
set protocols bgp group AS-300 neighbor 17.8.1.2

### Only one next hop selected:

root@R1# run show route protocol bgp 

inet.0: 25 destinations, 26 routes (25 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

192.168.123.0/24   *[BGP/170] 00:00:12, localpref 100
                      AS path: 200 I, validation-state: unverified
                    >  to 17.8.0.2 via ge-0/0/1.0
                    [BGP/170] 00:28:55, localpref 100
                      AS path: 300 I, validation-state: unverified
                    >  to 17.8.1.2 via ge-0/0/2.0

root@R1# run show route protocol bgp detail 

inet.0: 25 destinations, 26 routes (25 active, 0 holddown, 0 hidden)
192.168.123.0/24 (2 entries, 1 announced)
        *BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 598
                Address: 0x7bbeab4
                Next-hop reference count: 2, key opaque handle: 0x0, non-key opaque handle: 0x0
                Kernel Table Id: 0
                Source: 17.8.0.2
                Next hop: 17.8.0.2 via ge-0/0/1.0, selected
                Session Id: 356
                State: <Active Ext>
                Local AS:   100 Peer AS:   200
                Age: 1:03 
                Validation State: unverified 
                Task: BGP_200.17.8.0.2
                Announcement bits (2): 0-KRT 2-BGP_RT_Background 
                AS path: 200 I 
                Accepted
                Localpref: 100
                Router ID: 17.0.0.2
                Thread: junos-main 
         BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 597
                Address: 0x7bbeb24
                Next-hop reference count: 1, key opaque handle: 0x0, non-key opaque handle: 0x0
                Kernel Table Id: 0
                Source: 17.8.1.2
                Next hop: 17.8.1.2 via ge-0/0/2.0, selected
                Session Id: 355
                State: <Ext>
                Inactive reason: Active preferred
                Local AS:   100 Peer AS:   300
                Age: 29:46 
                Validation State: unverified 
                Task: BGP_300.17.8.1.2
                AS path: 300 I 
                Accepted
                Localpref: 100
                Router ID: 17.0.0.3
                Thread: junos-main 

Let’s load the multipath config. We must note that R1 receives the 2 paths from different AS numbers, by default Junos will not do any multipath in this case. But, there is solution, we can use the multipath multiple-as option to force Junos applying multipath on different ASs.

### Both neighbors must be multipath enabled !! 

root@R1# show | compare 
[edit protocols bgp group AS-200]
+     multipath {
+         multiple-as;
+     }
[edit protocols bgp group AS-300]
+     multipath {
+         multiple-as;
+     }

[edit]
root@R1# commit 
commit complete

### At this both next hops are being used:  

root@R1# run show route protocol bgp 

inet.0: 25 destinations, 26 routes (25 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

192.168.123.0/24   *[BGP/170] 00:02:52, localpref 100
                      AS path: 200 I, validation-state: unverified
                    >  to 17.8.0.2 via ge-0/0/1.0
                       to 17.8.1.2 via ge-0/0/2.0
                    [BGP/170] 00:34:26, localpref 100
                      AS path: 300 I, validation-state: unverified
                    >  to 17.8.1.2 via ge-0/0/2.0

root@R1# run show route protocol bgp detail 

inet.0: 25 destinations, 26 routes (25 active, 0 holddown, 0 hidden)
192.168.123.0/24 (2 entries, 1 announced)
        *BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 0
                Address: 0x7e80a3c
                Next-hop reference count: 2, key opaque handle: 0x0, non-key opaque handle: 0x0
                Kernel Table Id: 0
                Source: 17.8.0.2
                Next hop: 17.8.0.2 via ge-0/0/1.0, selected
                Session Id: 0
                Next hop: 17.8.1.2 via ge-0/0/2.0
                Session Id: 0
                State: <Active Ext>
                Local AS:   100 Peer AS:   200
                Age: 3:55 
                Validation State: unverified 
                Task: BGP_200.17.8.0.2
                Announcement bits (3): 0-KRT 2-BGP_RT_Background 3-BGP_Multi_Path 
                AS path: 200 I 
                Accepted Multipath
                Localpref: 100
                Router ID: 17.0.0.2
                Thread: junos-main 
         BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 597
                Address: 0x7bbeb24
                Next-hop reference count: 2, key opaque handle: 0x0, non-key opaque handle: 0x0
                Kernel Table Id: 0
                Source: 17.8.1.2
                Next hop: 17.8.1.2 via ge-0/0/2.0, selected
                Session Id: 355
                State: <Ext>
                Inactive reason: Active preferred
                Local AS:   100 Peer AS:   300
                Age: 35:29 
                Validation State: unverified 
                Task: BGP_300.17.8.1.2
                AS path: 300 I 
                Accepted MultipathContrib
                Localpref: 100
                Router ID: 17.0.0.3
                Thread: junos-main 

### But, there is only one next hop in the forwarding table !!! 

root@R1# run show route forwarding-table destination 192.168.123.0/24 
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index    NhRef Netif
192.168.123.0/24   user     0 17.8.0.2           ucst      598     4 ge-0/0/1.0

### Enable per-packet (really per-flow) load balancing for routes installed to kernel: 

root@R1# show | compare 
[edit policy-options]
+   policy-statement lb {
+       then {
+           load-balance per-packet;
+       }
+   }
[edit routing-options]
+   forwarding-table {
+       export lb;
+   }

[edit]
root@R1# commit 
commit complete

### Now we have both next hops installed: 

root@R1# run show route forwarding-table destination 192.168.123.0/24 
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index    NhRef Netif
192.168.123.0/24   user     0                    ulst  1048575     2
                              17.8.0.2           ucst      598     4 ge-0/0/1.0
                              17.8.1.2           ucst      597     4 ge-0/0/2.0


External Resources:

Leave a Reply