Verify: Keepalived IP Failover Working Or Not With tcpdump Command

I‘ve installed keepalived IP failover software as described here. But how do I verify it is working or not?

By default keepalived uses 224.0.0.18 IP address for VRRP (Virtual Router Redundancy Protocol) for communication between two nodes for health check. All you have to do is run tcpdump as follows on eth0 (or eth1) to make sure communication is established:
tcpdump -v -i eth0 host 224.0.0.18
tcpdump -vvv -n -i eth0 host 224.0.0.18

Sample outputs:

ADVERTISEMENTS

tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
16:54:01.743275 IP (tos 0x0, ttl 255, id 451, offset 0, flags [none], proto: VRRP (112), length: 96) 10.10.28.5 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 103, authtype simple, intvl 1s, length 76, addrs(15): 123.12.15.2,123.12.15.3[|vrrp]
16:54:02.744241 IP (tos 0x0, ttl 255, id 452, offset 0, flags [none], proto: VRRP (112), length: 96) 10.10.28.5 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 103, authtype simple, intvl 1s, length 76, addrs(15): 123.12.15.2,123.12.15.3[|vrrp]

Where,

  • 10.10.28.5 – your eth0 ip.
  • 123.12.15.2 and 123.12.15.3 – Virtual IPs manage by keepalived.
  • 224.0.0.18 – multicast request.

If you do not see any communication, than make sure keepalived service started on both nodes:
# service keepalived status
# service keepalived start

Make sure firewall is configured to accept accept multicast and vrrp protocol (IP Protocol # 112):
# /sbin/iptables -I INPUT -i eth0 -d 224.0.0.0/8 -j ACCEPT
# /sbin/iptables -A INPUT -p 112 -i eth0 -j ACCEPT
# /sbin/iptables -A OUTPUT -p 112 -o eth0 -j ACCEPT
# /sbin/service iptables save

Adjust above rules as per your interface and other requirements.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
3 comments… add one
  • Tapas Mallick Jul 4, 2010 @ 14:33

    instead of “# /sbin/iptables -I INPUT -i eth0 -d 224.0.0.0/8 -j ACCEPT”, I believe It should be “# /sbin/iptables -I INPUT -i eth0 -s 224.0.0.0/8 -j ACCEPT”, Please validate once and confirm.

  • eric Nov 9, 2010 @ 8:59

    no, just /sbin/iptables -I INPUT -i eth0 -d 224.0.0.0/8 -j ACCEPT!

  • Stefan May 2, 2012 @ 6:57

    Thanks a lot. It was very helpful!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.