Junos per packet load balancing

If you have two multiple equal cost paths to the same destination, JunOS behavior is to pick up one of the next-hops and use that one. For example in the following scenario, Junos keeps sending the packets via the ge-0/0/0.41 interface.

root@R4> show route 172.16.1.0

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

172.16.1.0/24      *[Static/5] 01:01:06
                    > to 10.30.41.31 via ge-0/0/0.41
                      to 10.30.40.30 via ge-0/0/0.40

but you can change this behavior ;

1) Write a policy statement

root@R4# show policy-options
policy-statement load_balance_per_packet {
    then {
        load-balance per-packet;
    }
}

2) Export this statement

[edit routing-options]
root@R4# show
forwarding-table {
    export load_balance_per_packet;
}

and here how it works;

root@R4> traceroute no-resolve 172.16.1.1
traceroute to 172.16.1.1 (172.16.1.1), 30 hops max, 40 byte packets
 1  10.30.41.31  3.825 ms 10.30.40.30  3.986 ms  3.997 ms
 2  10.20.30.2  3.992 ms  3.974 ms  4.001 ms
 3  172.16.1.1  5.963 ms  6.071 ms  3.974 ms

root@R4> traceroute no-resolve 172.16.1.1
traceroute to 172.16.1.1 (172.16.1.1), 30 hops max, 40 byte packets
 1  10.30.40.30  3.956 ms  3.986 ms 10.30.41.31  3.933 ms
 2  10.20.30.2  3.999 ms  4.073 ms  5.929 ms
 3  172.16.1.1  8.011 ms  7.949 ms  7.992 ms

I won’t lie it didn’t work this way when I tried this traceroute command first time. It worked actually but instead of 10.30.40.30 IP address on the first hop I was seeing 10.30.1.1 address which surprised me. Then I noticed that Junos is using the lowest IP address (10.30.1.1) on the configured interface as the source address and to change this behavior I type the following command on the other router ;

#set interfaces ge-0/0/1 unit 40 family inet address 10.30.40.30/24 primary

This command made this IP address primary because of which the expected output above displayed.

About: rtoodtoo

Worked for more than 10 years as a Network/Support Engineer and also interested in Python, Linux, Security and SD-WAN, currently living in the Netherlands and works as a Network Support Engineer. // JNCIE-SEC #223 / RHCE / PCNSE


3 thoughts on “Junos per packet load balancing”

  1. Hi,

    I am not really sure if per packet load balancing is being supported on SRX devices.
    It looks like what you have achieved here is “per flow load balancing”.

    Please refer the doc link and supported platforms, as M,T & PTX series.

    http://www.juniper.net/techpubs/en_US/junos12.3/topics/concept/policy-per-packet-load-balancing-overview.html

    Your blog has really good articles, appreciate your hardwork ! 🙂

    Can you please confirm the above query ?

    Regards,

    Sandeep.

  2. Hi Sandeep,
    I think you are right on that. Because configuration says it is per packet I always do this. I should have done the test with a TCP traffic to show that it is actually flow based. Thanks for pointing it out.

  3. does this type of configuration work for dual ISP ? A single SRX have two different ISPs, ISP A and ISP B. Will this configuration load balance the internet traffic destioned for 0.0.0/0 network with single source network say, 192.168.1.0/24?

Leave a Reply to Sandeep Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.