Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

close
keyboard_arrow_left
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Configuring Per-Packet Load Balancing

date_range 31-Jan-24

In Junos OS, you enable per-flow load balancing by setting the load-balance per-packet action in the routing policy configuration. The naming may be counter-intuitive, because in Junos, per-packet load balancing is functionally equivalent to what other vendors may term per-flow load balancing.

To configure per-packet load balancing, include the load-balance per-packet 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:

content_copy zoom_out_map
[edit policy-options policy-statement policy-name term term-name from]
route-filter destination-prefix match-type {
    load-balance per-packet;
}

or at the [edit policy-options policy-statement policy-name term term-name then] hierarchy level:

content_copy zoom_out_map
[edit policy-options policy-statement policy-name term term-name then]
load-balance per-packet;

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:

content_copy zoom_out_map
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:

content_copy zoom_out_map
[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:

  • 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:

content_copy zoom_out_map
[edit]
policy-options {
    policy-statement load-balancing-policy {
        then {
            load-balance per-packet;
        }
    }
}
routing-options {
    forwarding-table {
        export load-balancing-policy;
    }
}

Perform per-packet load balancing only for a limited set of routes:

content_copy zoom_out_map
[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-packet;
        }
    }
}
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:

content_copy zoom_out_map
[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

content_copy zoom_out_map
[edit routing-options forwarding-table]
export [ policy-names ];
external-footer-nav