Configuring Per-Flow Load Balancing
In Junos OS, you enable per-flow load balancing by setting the load-balance per-flow option in the routing policy configuration. Note that the existing load-balance per-packet option is also supported on Junos OS and Junos OS Evolved software.
When there are multiple equal-cost paths to the same destination for the active route, Junos OS uses a hash algorithm by default to choose one of the next-hop addresses to install in the forwarding table. When you use per-flow load balancing, all next-hop addresses for a destination destination are installed to the forwarding table. The load is thus balanced to spread traffic across multiple paths between routes.
To configure per-flow load balancing, include the load-balance per-packet
or
load-balance per-flow
statement either as an option of the
route-filter
statement at the [edit policy-options policy-statement
policy-name term term-name from]
hierarchy
level:
You can use the load-balance per-packet
or load-balance
per-flow
option, and both have the same functionality.
[edit policy-options policy-statement policy-name term term-name from] route-filter destination-prefix match-type { load-balance per-flow; }
or at the [edit policy-options policy-statement policy-name term
term-name then]
hierarchy level:
[edit policy-options policy-statement policy-name term term-name then] load-balance per-flow;
To complete the configuration you must apply the routing policy to routes exported from the
routing table to the forwarding table, by including the policy name in the list specified by
the export
statement:
export [ policy-names ];
You can include this statement at the following hierarchy levels:
-
[edit routing-options forwarding-table]
-
[edit logical-systems logical-system-name routing-options forwarding-table]
By default, Junos ignores port data when determining flows. To include port data in the flow
determination, include the family inet
statement at the
[edit forwarding-options hash-key]
hierarchy level:
[edit forwarding-options hash-key] family inet { layer-3; layer-4; }
If you include both the layer 3 and layer 4 statements, the device uses the following Layer 3 and Layer 4 information to load-balance:
-
Source IP address
-
Destination IP address
-
Protocol
-
Source port number
-
Destination port number
-
Incoming interface index
-
IP type of service
When all of the layer 3 and layer 4 parameters are identical, the device sends packets in the flow through the same interface, which in turn helps prevent out of order delivery for TCP and UDP flows..
Internet Control Message Protocol (ICMP) packets are handled differently because the field location offset is the checksum field, which makes each ping packet a separate “flow.” There are other protocols that can be encapsulated in IP that may have a varying value in the 32-bit offset. This may also be problematic because these protocols are seen as a separate flow.
With M Series (with the exception of the M120 router) and T Series routers, the first fragment is mapped to the same load-balanced destination as the unfragmented packets. The other fragments can be mapped to other load-balanced destinations.
For the M120 router only, all fragments are mapped to the same load-balanced destination. This destination is not necessarily the same as that for unfragmented packets.
By default, or if you include only the layer 3 statement, the router uses the incoming interface index as well as the following Layer 3 information in the packet header to load balance traffic:
-
PTX-1000
-
PTX-10002-60
-
QFX-10001-I-20c
-
QFX-10002-60c
-
QFX-10003-160c
-
QFX-10003-80c
-
Junos Evo PTX default configuration file
-
Junos PTX default configuration file
-
Source IP address
-
Destination IP address
-
Protocol
By default, IP version 6 (IPv6) packets are automatically load-balanced based on the following Layer 3 and Layer 4 information:
-
Source IP address
-
Destination IP address
-
Protocol
-
Source port number
-
Destination port number
-
Incoming interface index
-
Traffic class
Per-Packet Load Balancing Examples
Perform per-packet load balancing for all routes:
[edit] policy-options { policy-statement load-balancing-policy { then { load-balance per-flow; } } } routing-options { forwarding-table { export load-balancing-policy; } }
Perform per-packet load balancing only for a limited set of routes:
[edit] policy-options { policy-statement load-balancing-polic { from { route-filter 192.168.10/24 orlonger; route-filter 10.114/16 orlonger; } then { load-balance per-flow; } } } routing-options { forwarding-table { export load-balancing-policy; } }
To configure per-packet random spray load balancing, include the load-balance
random
statement at the [edit policy-options policy-statement
policy-name term term-name then]
hierarchy level:
[edit policy-options policy-statement policy-name term term-name then] load-balance random;
To complete the configuration you must apply the routing policy to routes exported from the
routing table to the forwarding table, by including the policy name in the list specified by
the export
statement at the [edit routing-options
forwarding-table]
hierarchy level
[edit routing-options forwarding-table] export [ policy-names ];