brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: let keepalived talk through ufw with proto vrrp

Ufw
~/tips/tip-ufw-proto-vrrp-keepalived

sudo ufw allow to 224.0.0.0/24 from 10.0.0.1 proto vrrp

Keepalived uses VRRP, protocol 112, which ufw only accepts in the full rule syntax.

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

More Ufw tips sudo ufw app update all sudo ufw show raw sudo ufw allow to 10.0.0.1 proto esp sudo ufw show listening grep IPV6 /etc/default/ufw All Ufw tips (32) All topics

Link