Protocol-Independent Routing · Topic 4 of 4

Load Balancing

Learn Junos load balancing for the JN0-364: per-prefix default, load-balance per-packet policy, forwarding-table export, BGP multipath and ulst checks.

  • 6 min
In a nutshell
  • Junos default: per-prefix, one next hop per destination prefix in the forwarding table.
  • Enable sharing with a policy containing then load-balance per-packet.
  • Apply it with set routing-options forwarding-table export <policy>.

What it is

Load balancing spreads traffic over several equal-cost paths to the same destination. Routing protocols such as OSPF and IS-IS find equal-cost paths on their own and put all of them in the routing table.

By default, Junos does per-prefix load balancing: for each destination prefix it installs one of the equal-cost next hops in the forwarding table. Different prefixes may use different links, but all traffic to one prefix uses one link. To install all next hops, you export a policy with load-balance per-packet to the forwarding table.

Routing tableseveral equal next hopsno policyForwarding tableone next hop per prefixRouting tableseveral equal next hopsload balance policyForwarding tableall next hops

How it works

Routing table compared with forwarding table

The routing table (inet.0) holds every next hop a protocol offers. The forwarding table is what the Routing Engine pushes down to the Packet Forwarding Engine (PFE). Load balancing is controlled at the point where routes move from one to the other.

DefaultWith per-packet policy
Next hops in inet.0All equal-cost next hopsAll equal-cost next hops
Next hops in forwarding tableOne, chosen per prefixAll equal-cost next hops
Traffic to one prefixOne linkSpread across links

Configuring load balancing

user@router# set policy-options policy-statement LB then load-balance per-packet
user@router# set routing-options forwarding-table export LB
user@router# commit

In hierarchy form:

policy-options {
    policy-statement LB {
        then {
            load-balance per-packet;
        }
    }
}
routing-options {
    forwarding-table {
        export LB;
    }
}

This policy has no from, so it applies to every route. You can limit it to some prefixes with a from route-filter term.

Per-packet really means per flow

Despite the keyword, MX Series routers with Trio line cards do not spray single packets across links. They hash header fields so every packet of one flow takes the same link, which keeps packets in order. The keyword per-packet is kept for historical reasons.

The fields in the hash are set under [edit forwarding-options enhanced-hash-key] on Trio platforms. By default the hash uses Layer 3 and Layer 4 header fields, so many flows between the same two hosts can still spread across links.

Packethash of header fieldsFlowsame link for every packetforwarding tableOne of several next hops

Where the equal paths come from

SourceEqual-cost paths
OSPF, IS-ISAutomatic when several paths have the same total metric
Static routeSeveral next-hop statements on one route
BGPOnly with multipath on the group or neighbor; otherwise BGP selects one best path
Aggregated EthernetHashing across member links happens inside the bundle, separate from this policy

A static route with two next hops:

user@router# set routing-options static route 10.40.0.0/16 next-hop [ 172.16.1.2 172.16.2.2 ]

BGP multipath for an internal group:

user@router# set protocols bgp group IBGP multipath

Verifying load balancing

First check the routing table. Several next hops listed means equal-cost paths exist.

user@router> show route 10.40.0.0/16 exact

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

10.40.0.0/16       *[OSPF/10] 00:05:31, metric 3
                    >  to 172.16.1.2 via ge-0/0/1.0
                       to 172.16.2.2 via ge-0/0/2.0

Only one next hop carries the > marker, the selected next hop. The marker stays on one next hop even after the load balancing policy is committed, so show route alone cannot prove load balancing.

Then check what the PFE uses:

user@router> show route forwarding-table destination 10.40.0.0/16
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index    NhRef Netif
10.40.0.0/16       user     0                    ulst  1048574     2
                              172.16.1.2         ucst      583     4 ge-0/0/1.0
                              172.16.2.2         ucst      584     4 ge-0/0/2.0

A next hop type of ulst (unilist) means a list of next hops is installed and traffic is shared. A single ucst (unicast) next hop means no load balancing for that prefix.

CommandWhat it shows
show route <prefix>How many equal-cost next hops exist
show route forwarding-table destination <prefix>ulst when several next hops are installed
show policy LBThe policy content
show configuration routing-options forwarding-tableWhether the export is applied
monitor interface trafficLive counters, to see traffic on each link
Exam tip

If show route lists two next hops but show route forwarding-table shows a single ucst next hop, the forwarding table export is missing or does not match the prefix.

Common mistakes

Applying the policy as a protocol export. load-balance per-packet only has its effect under routing-options forwarding-table export. As an OSPF or BGP export policy it does nothing for forwarding.

Expecting BGP to balance without multipath. BGP picks one best path. Without multipath, only one BGP next hop reaches the forwarding table even with the load balancing policy.

Testing with one flow. A single ping or file transfer is one flow, so it uses one link. Use many flows to see sharing.

Watch out

The paths must be truly equal. If one OSPF path has a total metric of 3 and the other 4, only the lower-cost path is in the routing table, and no policy can balance over the second path.

What to remember for the exam

  • Junos default: per-prefix, one next hop per destination prefix in the forwarding table.
  • Enable sharing with a policy containing then load-balance per-packet.
  • Apply it with set routing-options forwarding-table export <policy>.
  • On MX Trio, per-packet actually results in per-flow hashing; hash fields are under forwarding-options enhanced-hash-key.
  • OSPF and IS-IS install equal-cost paths automatically; BGP needs multipath.
  • show route marks one selected next hop with >, even with the policy; check the forwarding table instead.
  • show route forwarding-table shows ulst for a load balanced prefix.

Check yourself

  • Two equal OSPF paths exist, but traffic to one prefix uses only one link. Why?

    Junos installs one next hop per prefix by default; a load-balance per-packet policy must be exported to the forwarding table.

  • Where must a load-balance per-packet policy be applied to work?

    Under routing-options forwarding-table export.

  • Which next hop type in show route forwarding-table shows that load balancing is active?

    ulst, a unilist of several next hops, instead of a single ucst next hop.

Topic 4 of 4 in Protocol-Independent Routing

Test yourself on Protocol-Independent Routing

The full Juniper JNCIS-SP JN0-364 question bank has 860 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.