16.8.2 Configuring the Back-End Servers for Keepalived DR-Mode Load Balancing

The example configuration requires that the virtual IP address is configured on the master Keepalived server and on each back-end server. The Keepalived configuration maintains the virtual IP address on the master Keepalived server.

Only the master Keepalived server should respond to ARP requests for the virtual IP address. You can set the arp_ignore and arp_announce ARP parameters for the network interface of each back-end server so that they do not respond to ARP requests for the virtual IP address.

To configure the ARP parameters and virtual IP address on each back-end server:

  1. Configure the ARP parameters for the primary network interface, for example eth0:

    # echo "net.ipv4.conf.eth0.arp_ignore = 1" >> /etc/sysctl.conf
    # echo "net.ipv4.conf.eth0.arp_announce = 2" >> /etc/sysctl.conf
    # sysctl -p
    net.ipv4.conf.eth0.arp_ignore = 1
    net.ipv4.conf.eth0.arp_announce = 2
  2. To define a virtual IP address that persists across reboots, edit /etc/rc.local and add the command ip addr add 10.0.0.1/24 dev eth0, for example:

    # echo "ip addr add 10.0.0.1/24 dev eth0" >> /etc/rc.local
    # cat /etc/rc.local
    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
    
    touch /var/lock/subsys/local
    ip addr add 10.0.0.1/24 dev eth0

    This example defines the virtual IP address 10.0.0.1 for eth0 in addition to the existing real IP address of the back-end server.

  3. Reboot the system and verify that the virtual IP address has been set up:

    # ip addr show eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 08:00:27:cb:a6:8d brd ff:ff:ff:ff:ff:ff
        inet 10.0.0.72/24 brd 10.0.0.255 scope global eth0
        inet 10.0.0.1/24 brd 10.0.0.255 scope global secondary eth0
        inet6 fe80::a00:27ff:fecb:a68d/64 scope link 
           valid_lft forever preferred_lft forever