If you run keepalived on two machines and ufw is enabled, the nodes can drop each other’s VRRP announcements, because VRRP is not TCP or UDP. A port rule won’t fix that.
sudo ufw allow to 224.0.0.0/24 from 10.0.0.1 proto vrrp
The ufw man page lists exactly this example: keepalived is supported with the vrrp protocol, number 112, and the protocol can only be used with the full syntax. Replace 10.0.0.1 with the address of the other node. The destination in the example is a multicast range.
Do the same on both machines, each with the address of its peer as the from value. Then look at the result:
sudo ufw status numbered
One caveat: the man page says vrrp is valid without a port number. That means you leave the port out of the rule. I’d also add on INTERFACE to the rule when the machine has several network cards, because the man page’s full syntax allows in on INTERFACE, and a rule bound to the right card is easier to audit later.
Rules like this are easy to forget. When a node gets a new address, the from value on its peer has to change as well, so I’d note the peer addresses next to the keepalived config.
Further reading: ufw man page