Protocol Independent Routing · Topic 3 of 4

Load Balancing

Learn Junos equal cost multipath, default per-prefix load balancing, the load-balance per-packet policy and how to verify next hops for JN0-352.

  • 5 min
In a nutshell
  • ECMP needs equal preference and equal metric.
  • Default behavior is per-prefix: one next hop per prefix in the forwarding table.
  • then load-balance per-packet in a policy, exported with routing-options forwarding-table export, installs all next hops.

What it is

Load balancing means a router uses more than one next hop to reach the same destination. It needs equal cost multipath (ECMP): two or more routes to one prefix that tie on preference and on the metric.

Junos OS does not spread traffic over all those paths by default. It has two separate steps, and the exam tests both: which next hops are kept for a prefix, and how traffic is divided among them.

Equal cost routessame preference and metrickept asSeveral next hopsin route tabledefaultOne next hop per prefixSeveral next hopsper packet policyAll next hops usedhashed per flow

How it works

Step 1: equal cost routes in the routing table

A routing protocol such as OSPF or IS IS installs multiple next hops when two paths have the same cost. A static route can list more than one next-hop.

user@router# set routing-options static route 10.50.0.0/16 next-hop 192.168.1.2
user@router# set routing-options static route 10.50.0.0/16 next-hop 192.168.2.2

show route then lists both next hops. One is marked with >, the selected next hop.

user@router> show route 10.50.0.0/16

10.50.0.0/16       *[Static/5] 00:03:41
                    >  to 192.168.1.2 via ge-0/0/0.0
                       to 192.168.2.2 via ge-0/0/1.0

BGP is an exception: it keeps only one best path unless multipath is configured in the BGP group.

Step 2: the default is per-prefix

By default the router installs one of the equal cost next hops in the forwarding table for each prefix. Different prefixes may use different next hops, but all traffic to one prefix uses one path. This is called per-prefix load balancing.

The load-balance per-packet policy

To use all next hops, you create a routing policy with the action load-balance per-packet and export it to the forwarding table:

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

The name is misleading. On current hardware the router does not alternate packets. It calculates a hash from packet header fields, such as addresses and protocol and port numbers, and maps each flow to one next hop. All packets of one flow stay on one path, which prevents packet reordering, while different flows spread across the links.

BehaviorDefaultWith the per-packet policy exported
Next hops in forwarding tableOne per prefixAll equal cost next hops
DistributionPer prefixHashed per flow
Packet reorderingNot possibleNot within a flow
Watch out

The policy must be applied under forwarding-table export. Applying a policy with load-balance per-packet to a routing protocol (protocols ospf export) does nothing for load balancing.

Policythen load balance per packetexported toForwarding tableinstallsAll next hopsulst entry

Verifying

Look at the routing table first, then the forwarding table.

user@router> show route 10.50.0.0/16 exact
user@router> show route forwarding-table destination 10.50.0.0/16
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index    NhRef Netif
10.50.0.0/16       user     0                    ulst  1048574     2
                              192.168.1.2        ucst      590     3 ge-0/0/0.0
                              192.168.2.2        ucst      591     3 ge-0/0/1.0

A ulst (unilist) next hop type with several ucst entries means traffic is balanced across them. A single ucst next hop means only one path is in use, even if show route listed two.

show interfaces <name> extensive and show interfaces <name> statistics let you compare traffic counters on the member links. A well balanced result has similar counters when there are many flows, but a few large flows can land on one link, because the hash is per flow.

Why traffic may not balance

  • The routes are not equal cost, for example OSPF paths with different metrics.
  • The routes have different preferences, so only the best one is active.
  • The per-packet policy is missing or applied to the wrong place.
  • There are very few flows, so the hash puts them on one link.
  • A BGP prefix has no multipath.

Static routes and an equal split

A static route with several next hops is a valid ECMP route in the routing table. Without the forwarding table policy, traffic to that one prefix still follows a single next hop.

Exam tip

To prove the exam answer on a router, run show route forwarding-table for one prefix before and after the policy. The change from one ucst to a ulst shows the policy is working.

Common mistakes

Thinking ECMP in show route means traffic is balanced. The routing table can list several next hops while the forwarding table uses one. Check show route forwarding-table.

Exporting the policy to the wrong place. Only routing-options forwarding-table export uses it for balancing.

Expecting packet by packet distribution. The keyword says per-packet but the behavior is a hash per flow on current platforms.

Expecting unequal cost balancing from OSPF. Junos OSPF load balances only over paths with equal cost.

What to remember for the exam

  • ECMP needs equal preference and equal metric.
  • Default behavior is per-prefix: one next hop per prefix in the forwarding table.
  • then load-balance per-packet in a policy, exported with routing-options forwarding-table export, installs all next hops.
  • The traffic is hashed per flow, not sent packet by packet.
  • BGP needs multipath to keep more than one path.
  • show route forwarding-table shows ulst when several next hops are used.
  • show route marks the selected next hop with >.

Check yourself

  • What is the default load balancing behavior in Junos for a prefix with several equal cost next hops?

    Per-prefix: one next hop is installed in the forwarding table for each prefix, so all traffic to that prefix uses one path.

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

    Under routing-options forwarding-table export, so that all equal cost next hops are installed in the forwarding table.

  • Which show command proves several next hops are really in use?

    show route forwarding-table destination <prefix>, which shows a ulst next hop with several member next hops.

Topic 3 of 4 in Protocol Independent Routing

Test yourself on Protocol Independent Routing

The full Juniper JNCIS-ENT JN0-352 question bank has 846 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.