WeOS
5.20.1

# VRRP Load Balancing HowTo

## About

This document provides a VRRP Load Balancing use-case, and how it is configured using the CLI.

For an overview of all available configuration settings for VRRP refer to the configuration guide:

- VRRP Configuration Guide

## Introduction

It is possible to configure VRRP to perform some limited load balancing, an example of this can be observed in Figure 1 below.

                                       |
                                   .--.-.
                                  ( (    )__
                                 (_,  \ ) ,_)  Network N2
                                   '-'--`--'
                                    |
                  ---------+--------+--------+---------
                           |                 |
    VRRP Setup             |                 |             VRRP Setup
    instance: i1           |                 |             instance: i1
    vrid: 1                |                 |             vrid: 1
    vaddr: 10.0.0.100      |                 |             vaddr: 10.0.0.100
    prio: 100          .---+---.         .---+---.         prio: 50
                       |       |         |       |
                       |  R1   |         |  R2   |
    VRRP Setup         |       | vlan1   |       | vlan1   VRRP Setup
    instance: i2       '---+---'         '---+---'         instance: i2
    vrid: 2                |.1               |.2           vrid: 2
    vaddr: 10.0.0.101      |                 |             vaddr: 10.0.0.101
    prio: 50               |                 |             prio: 100
                           |                 |
                           |                 |
                  --+------+---Network N1----+------+--
                    |      |   10.0.0.0/24   |      |
                    |      |               .-+--. .-+--.
                    |      |               | H3 | | H4 | route to N2 via 10.0.0.101
                    |      |               '----' '----'
                  .-+--. .-+--.
                  | H1 | | H2 | route to N2 via 10.0.0.100
                  '----' '----'

Figure 1: A VRRP setup with two routers forming a virtual router that performs load balancing on traffic from Network N1 to Network N2.

In this case, two instances i1 and i2, with VRIDs 1 and 2 respectively, have been set up on each of the participating routers R1 and R2. The priorities are chosen so that by default R1 is the master router for VRID 1 (the virtual router 10.0.0.100), and R2 is the VRID 2 (10.0.0.101) master. Then, on network N1, hosts H1 and H2 are set up with a route to network N2 via 10.0.0.100, while hosts H3 and H4 use 10.0.0.101 instead. Due to the (presumably static) configuration of routes in this manner, as long as both R1 and R2 are up, traffic from N1 will be divided (though not actually balanced) between the two physical routers.

The need for the user to manually configure relevant hosts, and achieve a level of load splitting by statically moving hosts between virtual routers, shows some of the limitations of VRRP as a load-balancing system.

## Configuration

Configure two VRRP instances on each of the routers. We configure the instances so that each physical router will become master for one of the virtual routers each.

It is assumed that both routers VLANs configured for each of the networks described in Figure 1.

### Router 1

Configure VRRP instance i1:

    R1:/#> configure
    R1:/config/#> router
    R1:/config/router/#> vrrp i1
    Creating new VRRP instance: i1
    R1:/config/router/vrrp-i1/#> vrid 1
    R1:/config/router/vrrp-i1/#> address 10.0.0.100
    R1:/config/router/vrrp-i1/#> prio 100
    R1:/config/router/vrrp-i1/#> iface vlan1
    R1:/config/router/vrrp-i1/#> preempt delay 0
    R1:/config/router/vrrp-i1/#> end
    R1:/config/router/#>

Configure VRRP instance i2:

    R1:/config/router/#> vrrp i2
    Creating new VRRP instance: i2
    R1:/config/router/vrrp-i2/#> vrid 2
    R1:/config/router/vrrp-i2/#> address 10.0.0.101
    R1:/config/router/vrrp-i2/#> prio 50
    R1:/config/router/vrrp-i2/#> iface vlan1
    R1:/config/router/vrrp-i2/#> preempt delay 0
    R1:/config/router/vrrp-i2/#> leave
    R1:/#>

### Router 2

Configure VRRP instance i1:

    R2:/#> configure
    R2:/config/#> router
    R2:/config/router/#> vrrp i1
    Creating new VRRP instance: i1
    R2:/config/router/vrrp-i1/#> vrid 1
    R2:/config/router/vrrp-i1/#> address 10.0.0.100
    R2:/config/router/vrrp-i1/#> prio 50
    R2:/config/router/vrrp-i1/#> iface vlan1
    R2:/config/router/vrrp-i1/#> preempt delay 0
    R2:/config/router/vrrp-i1/#> end
    R2:/config/router/#>

Configure VRRP instance i2:

    R2:/config/router/#> vrrp i2
    Creating new VRRP instance: i2
    R2:/config/router/vrrp-i2/#> vrid 2
    R2:/config/router/vrrp-i2/#> address 10.0.0.101
    R2:/config/router/vrrp-i2/#> prio 100
    R2:/config/router/vrrp-i2/#> iface vlan1
    R2:/config/router/vrrp-i2/#> preempt delay 0
    R2:/config/router/vrrp-i2/#> leave
    R2:/#>

## Status

The status of the VRRP can be observed on each individual VRRP router.

Router 1:

    R1:/#> show vrrp
    VRRP INSTANCE     INTERFACE         VRID  PRIORITY   STATE  GROUPED       GROUP
    i2                vlan1                2        50   BACKUP   N        --------
    i1                vlan1                1       100   MASTER   N        --------

Router 2:

    R2:/#> show vrrp
    VRRP INSTANCE     INTERFACE         VRID  PRIORITY   STATE  GROUPED       GROUP
    i2                vlan1                2       100   MASTER   N        --------
    i1                vlan1                1        50   BACKUP   N        --------

As can be seen the master for the virtual router with vrid 1 is router R1 and the master for the virtual router with vrid 2 is router R2.

« Previous Next »