I am working in bare metal environment trying to setup HA loadbalancing using keepalived. When I try to ping the VIP which I given in keepalived config file from other machines in the same network its not reachable, but when I stop keepalived in one of the machines, the other becomes master and IP address is assigned automatically.
keepalived configuration
vrrp_instance VI_PUB
{
interface ens34
state MASTER
virtual_router_id 52
priority 101
virtual_ipaddress
{
192.167.3.54
}
track_interface
{
ens34
}
}
virtual_server 192.167.3.54 8081
{
delay_loop 4
lb_algo sh # source hash
lb_kind NAT
protocol TCP
real_server 172.16.3.23 8080
{
weight 1
TCP_CHECK
{
connect_timeout 15
nb_get_retry 3
delay_before_retry 2
}
}
real_server 172.16.3.24 8080
{
weight 1
TCP_CHECK
{
connect_timeout 15
nb_get_retry 3
delay_before_retry 2
}
}
}
ip addr show ens32
on current master
ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:43:c2:9c brd ff:ff:ff:ff:ff:ff
inet 172.16.3.24/23 brd 172.16.3.255 scope global ens32
valid_lft forever preferred_lft forever
inet 192.167.3.54/32 scope global ens32
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe43:c29c/64 scope link
valid_lft forever preferred_lft forever
route -n
on current master
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.2.1 0.0.0.0 UG 0 0 0 ens32
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 ens32
172.16.2.0 0.0.0.0 255.255.254.0 U 0 0 0 ens32
route -n
on one of the hosts in the current network
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.2.1 0.0.0.0 UG 0 0 0 ens34
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 ens34
172.16.2.0 0.0.0.0 255.255.254.0 U 0 0 0 ens34
any help would be appreciated..!
Best Answer
I guess that
will show that your virtual address is
/32 is usually not the desired result, therefore you should add e.g. /24: