Juniper MX BGP load balancing.

This article aims to offer a short explanation of BGP load balancing on a Juniper MX series router. Normally, a Juniper router running BGP will select a single best route based on the following selection procedure. By default, only one route will be selected as active and only one next-hop is installed in the forwarding table. As a result, routers peering across multiple links will only use one of these links.

To start load balancing, BGP multipathing has to be enabled. When BGP multipathing is enabled, and when multiple copies of a route make it to the RID and the peer ID selection in the BGP route selection process, multiple copies of that route can be installed into the routing table.

Simply enabling BGP multipathing is not enough. This is because enabling BGP multipathing will only have multiple copies of a route installed into the routing table, not the forwarding table. Juniper requires that you enable BGP multipathing and load-balancing before the routes are actually installed into the forwarding table.

This concept is applicable to both IBGP and EBGP. Also nice to know is the fact that it is also possible to use BGP to load balance across unequal-cost paths while utilizing communities to signal the available bandwidth per link. Since I am keeping it simple here, I will not go in to this.



Load balancing across two EBGP sessions.

The configuration to enable BGP load balancing across two EBGP sessions is relatively straightforward on Junos. I will demonstrate it using the following setup:



scenario


There are two EBGP peering sessions established between the Trajan and the Aurelius router. The Trajan router is advertising the 192.168.1.0/24 subnet to the Aurelius router. The configuration on the Aurelius router is as follows;

 
set routing-options autonomous-system 65001
set protocols bgp group ebgp neighbor 2.0.0.14 peer-as 65000
set protocols bgp group ebgp neighbor 2.0.0.5 peer-as 65000
                

The Aurelius router is receiving the prefix from the Trajan router across both EBGP sessions:

                 
play@MX480-TEST:AURELIUS> show bgp summary
Groups: 1 Peers: 2 Down peers: 0
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0                 2          1          0          0          0          0
Peer                     AS      InPkt     OutPkt    OutQ   Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...
2.0.0.5               65000         38         36       0       0       15:17 1/1/1/0              0/0/0/0
2.0.0.14              65000         41         39       0       5       16:25 0/1/1/0              0/0/0/0

play@MX480-TEST:AURELIUS> show route protocol bgp

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

192.168.1.0/24     *[BGP/170] 00:13:31, localpref 100
                      AS path: 65000 I
                    > to 2.0.0.5 via xe-0/2/0.2
                    [BGP/170] 00:13:31, localpref 100
                      AS path: 65000 I
                    > to 2.0.0.14 via xe-0/3/0.4
                

By default, Junos will install only one next-hop in the routing table, based on the following selection procedure. To start load balancing, the first step will be to enable BGP multipath. BGP multipath can be enabled using the following command;

 
set protocols bgp group ebgp multipath
                

By enabling BGP multipath, Aurelius will be able to install multiple BGP routes into the routing table;

 
play@MX480-TEST:AURELIUS> show bgp neighbor 2.0.0.5 | match opti
  Options: <Preference PeerAS Refresh>
play@MX480-TEST:AURELIUS> show route 192.168.1.0

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

192.168.1.0/24     *[BGP/170] 00:10:52, localpref 100
                      AS path: 65000 I
                    > to 2.0.0.5 via xe-0/2/0.2
                    [BGP/170] 00:10:52, localpref 100
                      AS path: 65000 I
                    > to 2.0.0.14 via xe-0/3/0.4

play@MX480-TEST:AURELIUS> configure
Entering configuration mode

[edit]
play@MX480-TEST:AURELIUS# set protocols bgp group ebgp multipath

[edit]
play@MX480-TEST:AURELIUS# commit and-quit
commit complete
Exiting configuration mode

play@MX480-TEST:AURELIUS> show route 192.168.1.0

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

192.168.1.0/24     *[BGP/170] 00:11:07, localpref 100, from 2.0.0.5
                      AS path: 65000 I
                      to 2.0.0.5 via xe-0/2/0.2
                    > to 2.0.0.14 via xe-0/3/0.4
                    [BGP/170] 00:11:07, localpref 100
                      AS path: 65000 I
                    > to 2.0.0.14 via xe-0/3/0.4

play@MX480-TEST:AURELIUS> show bgp neighbor 2.0.0.5 | match Options
  Options: <Preference PeerAS Multipath Refresh>
                

After enabling BGP multipath, the second ‘show route’ is displaying two next-hops associated with the 192.168.1.0/24 route. The configuration did not actually enable load balancing just yet. Junos only installed the prefixes in the routing table and not in the forwarding table:

                 
play@MX480-TEST:AURELIUS> show route 192.168.1.0

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

192.168.1.0/24     *[BGP/170] 00:10:19, localpref 100, from 2.0.0.5
                      AS path: 65000 I
                      to 2.0.0.5 via xe-0/2/0.2
                    > to 2.0.0.14 via xe-0/3/0.4
                    [BGP/170] 00:11:06, localpref 100
                      AS path: 65000 I
                    > to 2.0.0.14 via xe-0/3/0.4

play@MX480-TEST:AURELIUS> show route forwarding-table matching 192.168.1.0
Logical system: AURELIUS
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
192.168.1.0/24     user     0 2.0.0.14           ucst  1662     5 xe-0/3/0.4

Logical system: AURELIUS
Routing table: __master.anon__.inet
Internet:
                

To have the router install both routes in the forwarding table, the following configuration needs to be added;

                    
set policy-options policy-statement bgp-load-balance-example then load-balance per-packet
set routing-options forwarding-table export bgp-load-balance-example
                 

After issuing a commit, we can see a ‘ulst’ (unilist or list of unicast next hops) appear in the forwarding table:

                  
play@MX480-TEST:AURELIUS> show route forwarding-table matching 192.168.1.0
Logical system: AURELIUS
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
192.168.1.0/24     user     0                    ulst 1048574     2
                              2.0.0.5            ucst  1661     3 xe-0/2/0.2
                              2.0.0.14           ucst  1662     4 xe-0/3/0.4
                 


Load balancing across 1 EBGP session.

We can also decide to use a different approach and achieve load balancing across multiple links using a single BGP peering session:



scenario


To setup this BGP peering session, we need to establish IP connectivity between the loopback addresses of both routers. To this end, we start off with the following configuration commands on Aurelius;

                  
set routing-options static route 1.1.1.2/32 next-hop 2.0.0.14
set routing-options static route 1.1.1.2/32 next-hop 2.0.0.5
                 

Since the TTL for all EBGP packets is set to 1 by default, we need to alter this behavior using the ‘multihop’ statement. The ‘multihop’ statement will change the TTL into a specified number (or 64 when it is configured without a value) .

In addition to this, we will need to configure multipath and we will also need to configure the session to use the loopback IP address as a source address:

                    
set protocols bgp group ebgp multipath
set protocols bgp group ebgp neighbor 1.1.1.2 multihop ttl 1
set protocols bgp group ebgp neighbor 1.1.1.2 local-address 1.1.1.1
set protocols bgp group ebgp neighbor 1.1.1.2 peer-as 65000
                 

The final step is configuring the router to install both prefixes into the forwarding table:

                  
set policy-options policy-statement bgp-load-balance-example then load-balance per-packet
set routing-options forwarding-table export bgp-load-balance-example
                 

After completing these configuration items, we can verify the result on the Aurelius router in the following way:

                  
play@MX480-TEST:AURELIUS> show route 192.168.1.0 extensive

inet.0: 7 destinations, 8 routes (7 active, 0 holddown, 0 hidden)
192.168.1.0/24 (1 entry, 1 announced)
TSI:
KRT in-kernel 192.168.1.0/24 -> {indirect(1048575)}
        *BGP    Preference: 170/-101
                Next hop type: Indirect
                Address: 0x8f995f8
                Next-hop reference count: 4
                Source: 1.1.1.2
                Next hop type: Router, Next hop index: 1048574
                Next hop: 2.0.0.5 via xe-0/2/0.2
                Next hop: 2.0.0.14 via xe-0/3/0.4, selected
                Protocol next hop: 1.1.1.2
                Indirect next hop: 8f962d0 1048575
                State: <Active Ext>
                Local AS: 65001 Peer AS: 65000
                Age: 10:39      Metric2: 0
                Task: BGP_65000.1.1.1.2+179
                Announcement bits (2): 0-KRT 4-Resolve tree 1
                AS path: 65000 I
                Accepted
                Localpref: 100
                Router ID: 1.1.1.2
                Indirect next hops: 1
                        Protocol next hop: 1.1.1.2
                        Indirect next hop: 8f962d0 1048575
                        Indirect path forwarding next hops: 2
                                Next hop type: Router
                                Next hop: 2.0.0.5 via xe-0/2/0.2
                                Next hop: 2.0.0.14 via xe-0/3/0.4
                        1.1.1.2/32 Originating RIB: inet.0
                          Node path count: 1
                          Forwarding nexthops: 2
                                Nexthop: 2.0.0.5 via xe-0/2/0.2
                                Nexthop: 2.0.0.14 via xe-0/3/0.4

play@MX480-TEST:AURELIUS> show route forwarding-table matching 192.168.1.0
Logical system: AURELIUS
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
192.168.1.0/24     user     0                    indr 1048575     2
                                                 ulst 1048574     4
                              2.0.0.5            ucst  1661     3 xe-0/2/0.2
                              2.0.0.14           ucst  1662     3 xe-0/3/0.4

Logical system: AURELIUS
Routing table: __master.anon__.inet
Internet:
                 


23-12-2014