4

my keepalived configuration is not working correctly.

I have two virtual testing machines (virtualbox) to try some things out with keepalived/vrrp. Bot can ping each other flawlessly (internal virtualbox network).

VM 1 (MASTER):

eth0: Management
eth1: 192.168.2.1/24
eth2: 192.168.2.2/24

keepalived.conf:

vrrp_instance test {
state MASTER
interface eth1
track_interface {
        eth2
}
virtual_router_id 1
priority 101
advert_int 1
authentication {
        auth_type PASS
        auth_pass 1111
}
virtual_ipaddress {
        192.168.3.1/24 dev eth1
        192.168.3.2/24 dev eth2
}
}

tcpdump on eth1:

12:44:54.720119 IP 192.168.2.1 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 1, prio 101, authtype simple, intvl 1s, length 24
12:44:55.049465 IP 192.168.2.3 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 1, prio 100, authtype simple, intvl 1s, length 24

tcpdump on eth2:

12:46:21.082264 IP 192.168.2.1 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 1, prio 101, authtype simple, intvl 1s, length 24
12:46:21.494239 IP 192.168.2.3 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 1, prio 100, authtype simple, intvl 1s, length 24

VM 2 (BACKUP):

eth0: Management
eth1: 192.168.2.3/24
eth2: 192.168.2.4/24

keepalived.conf:

vrrp_instance test {
state BACKUP
interface eth1
track_interface {
        eth2
}
virtual_router_id 1
priority 100
advert_int 1
authentication {
        auth_type PASS
        auth_pass 1111
}
virtual_ipaddress {
        192.168.3.1/24 dev eth1
        192.168.3.2/24 dev eth2
}
}

tcpdump on eth1:

12:53:12.265456 IP 192.168.2.1 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 1, prio 101, authtype simple, intvl 1s, length 24
12:53:12.670635 IP 192.168.2.3 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 1, prio 100, authtype simple, intvl 1s, length 24

tcpdump on eth2:

12:53:34.397374 IP 192.168.2.1 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 1, prio 101, authtype simple, intvl 1s, length 24
12:53:34.787327 IP 192.168.2.3 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 1, prio 100, authtype simple, intvl 1s, length 24

After starting keepalived on VM 2, it transits instantly to the master state, which shouldnt be.

Why is this happening?

carrot
  • 77
  • 1
  • 1
  • 10

1 Answers1

0

Are eth1 and eth2 on the same physical (virtual-physical) subnet? If not, it seems a little odd that you have two different interfaces on each host with IPs on the same subnet, and that you're assigning IPs to each of the interfaces that are on the same subnet. I'd suggest trying out:

VM 1: eth1 - 192.168.101.2/24, eth2 - 192.168.102.2/24
VM 2: eth1 - 192.168.101.3/24, eth2 - 192.168.102.3/24
VRRP: eth1 - 192.168.101.1/24, eth2 - 192.168.103.1/24

This puts the addresses on each of the interfaces on the same subnets, but on different subnets from the other interfaces on the same host. I'm not certain this is causing problems, but it seems like it could, as your hosts will have two different device routes to the same subnet, which could be confusing keepalived and/or VRRP. I think this is generally how you see VRRP work on things like Cisco routers, for example - you'll see a virtual IP address and then the physical IPs of the two devices, all on the same subnet.

The other thing that seems to be recommended in the keepalived documentation is to put the priority 50-ish points apart - so, set MASTER at 150 and BACKUP at 100.

Colt
  • 1,939
  • 6
  • 20
  • 25