Keepalived

Configuration to implement simple VRRP with Keepalived.

Class B Network 192.168.0.0

ISP

| -eth0 192.168.2.254

|-lb0--[

| -eth0:0 192.168.255.1 VIP

|

| -eth0 192.168.3.254

|-lb1--[

-eth0:0 192.168.255.1 VIP

! Configuration File for keepalived

global_defs {

notification_email {

james@callfire.com

}

notification_email_from keepalived@callfire.com

smtp_server 192.168.255.1

smtp_connect_timeout 30

router_id CORESITE-director1

}

vrrp_script chk_haproxy { # Requires keepalived-1.1.13

script "killall -0 haproxy" # cheaper than pidof

interval 2 # check every 2 seconds

weight 2 # add 2 points of prio if OK

}

vrrp_instance VIRTUAL_ROUTER1 {

interface eth0

state MASTER

virtual_router_id 51

priority 101 # highest number is your master

garp_master_delay 2

advert_int 1

smtp_alert

virtual_ipaddress {

192.168.255.1/16 label eth0:0

}

track_script {

chk_haproxy

}

}

I then setup nat with iptables on both lb0 and lb1. This will give you redundant nat gateways on your subnet.

[troubleshooting]

$ ip addr list eth0

References:

http://serverfault.com/questions/170515/connection-sync-suggestions-with-haproxy-and-keepalived

http://haproxy.1wt.eu/download/1.3/doc/architecture.txt