Keep Your Self-Hosted Services Online: Why I Use Keepalived in My Home Lab

As my home network has grown and I rely more on services I host myself, keeping everything running smoothly becomes crucial. Unlike cloud services that someone else manages, outages in my home lab are my problem, and nobody likes their internet or smart home gadgets suddenly stopping. That’s where a clever tool called Keepalived comes in, helping ensure key services stay available even if one server stumbles. The main benefit? Using a single “virtual” address that always points to a working server, making my home lab much more resilient.

Why High Availability Matters for Self-Hosting

Choosing to self-host gives you more control and privacy over your data compared to relying on big companies’ servers. But with that control comes the responsibility of keeping things online. A single server going down can mean your ad blocker stops working, your smart lights are unresponsive, or you can’t access your files remotely.

I’ve taken steps like setting up a high-availability Proxmox cluster for my virtual machines, which helps a lot. But network access to those VMs is still critical. If the server hosting a VM is fine, but the network path to it fails, the service is still down. This is where Keepalived offers an extra layer of protection.

How Keepalived Works (Simply Explained)

Keepalived uses something called VRRP, or Virtual Router Redundancy Protocol. Think of it like having two identical machines ready to do the same job, but they share one special “phone number” (an IP address) that the rest of your network uses to reach them.

One machine is the “master,” and the other is the “backup.” Keepalived constantly checks if the master is healthy. If the master goes down for any reason, Keepalived automatically switches the special shared IP address over to the backup machine. Your devices only ever need to know the one special IP, and Keepalived handles directing traffic to whichever server is currently active. It’s a simple yet powerful way to add failover without needing complex setups.

Some might suggest tools like HAProxy for failover and load balancing. While HAProxy is great, you still need a way to ensure HAProxy itself doesn’t become a single point of failure. Often, Keepalived is used in front of HAProxy instances for exactly that reason! For me, focusing on simple, reliable failover with Keepalived for key services was the logical first step.

Multiple SD cards next to a Raspberry Pi board, symbolizing self-hosting on small devices.Multiple SD cards next to a Raspberry Pi board, symbolizing self-hosting on small devices.

You can delegate some tasks to smaller devices like Raspberry Pis to distribute your workload and reduce dependency on a single powerful server. For example, here are 5 services I self-host on my Raspberry Pi instead of my main home server.

Where I Use Keepalived in My Home Lab

I’ve integrated Keepalived into several critical parts of my setup to eliminate potential downtime.

Keeping My DNS Always On

Self-hosting your own DNS server, like Pi-hole or Technitium, is fantastic for privacy and blocking ads across your entire network. It prevents your internet provider or other third parties from seeing every website you visit via DNS requests. As my colleague Adam recommends, having two Pi-hole servers is a smart move so one can take over if the other fails.

I use Technitium, which is very capable. While it plans to add native clustering in the future, for now, I use Keepalived. I run two instances of Technitium (one on my NAS, one on a mini PC) and use Keepalived to give them a single shared IP address. If one server goes offline, Keepalived quickly moves the shared IP to the other, ensuring my network’s DNS resolution never skips a beat.

Setting this up just required a small system tweak on the servers and configuring Technitium and Keepalived to use the shared “virtual” IP alongside their regular IP addresses.

net.ipv4.ip_nonlocal_bind=1

This command allows the server process (like Technitium) to bind to an IP address that doesn’t “belong” to that server specifically, enabling the use of the virtual IP.

A laptop screen showing the dashboard of a Pi-hole DNS server.A laptop screen showing the dashboard of a Pi-hole DNS server.

If you’re diving into self-hosting, especially something like Pi-hole, be sure to learn from others’ experiences. Here’s a look at a mistake I made when self-hosting Pi-hole that you should avoid.

Ensuring My Smart Home Stays Smart

I rely on Home Assistant to automate my smart home and tie together devices from different brands. It’s frustrating when a simple network hiccup means my lights or sensors stop working. Just as you expect cloud-based smart home systems like Google Home or HomeKit to always be online, I want my self-hosted Home Assistant to be just as reliable.

Using Keepalived, I run a primary Home Assistant instance (as a VM on my NAS) and a backup (a Docker container on another machine). Keepalived checks the primary VM’s status. If it becomes unreachable, the backup Docker instance takes over the shared IP. With Home Assistant Cloud backups, keeping the two instances in sync is straightforward. While the Docker version might not handle every single add-on I use, it covers the essentials, keeping my core smart home functionality alive during any brief outage of the primary server.

A Home Assistant dashboard interface with various smart home controls.A Home Assistant dashboard interface with various smart home controls.

The platform you run Home Assistant on also impacts performance and reliability. I recently shared how moving my Home Assistant from TrueNAS to a mini PC running Proxmox improved things for me.

Making Sure Access Never Stops

A reverse proxy is key for securely accessing my self-hosted services from outside my network or even simplifying access within my network. It acts as a single front door, routing requests to the correct service behind the scenes. This makes the reverse proxy a critical single point of failure.

Whether I’m using Nginx or HAProxy for this, integrating Keepalived is quite simple. I set up two reverse proxy instances on different servers and use Keepalived to manage a shared virtual IP for them. It requires three IP addresses in total: the IPs for the two servers and the one shared virtual IP. Remember to set different “priorities” for the two Keepalived instances so one knows it’s the primary and the other is the backup.

One small hurdle I hit initially was firewall rules. Keepalived uses specific network protocols (like VRRP) to communicate between the master and backup servers. I needed to explicitly allow these through my firewall:

$ sudo iptables -I INPUT -p 112 -d 224.0.0.18 -j ACCEPT
$ sudo iptables -I INPUT -p 51 -d 224.0.0.18 -j ACCEPT

These commands allow traffic on protocol 112 (VRRP) and 51 (authentication header, often used by VRRP) to the multicast address Keepalived uses for communication. Adding these rules got everything working smoothly.

A small rack of server equipment representing a home lab setup with Proxmox.A small rack of server equipment representing a home lab setup with Proxmox.

If you’re not already using them, reverse proxies are incredibly handy in a home lab. Here’s how to set up Nginx reverse proxies in your own setup.

Your Remote Connection, Uninterrupted

Remote access to my home network via VPN is essential for managing my services and accessing files when I’m away. If my VPN server goes down, that connection is severed, leaving me stranded.

To prevent this, I run my OpenVPN server on two different machines. Just like with other services, I use Keepalived to assign a single virtual IP address that both VPN servers listen on. This virtual IP is what I configure my remote devices to connect to. If the primary VPN server becomes unavailable, Keepalived automatically switches the virtual IP to the secondary server. My remote device might briefly disconnect, but it can immediately reconnect using the same address, which now points to the backup server.

A person browsing a secure website on a laptop, illustrating remote access and VPN.A person browsing a secure website on a laptop, illustrating remote access and VPN.

If both VPN servers somehow failed, I’d have bigger issues than just remote access! While I could use alternatives like Pangolin for remote access, the underlying issue of service availability remains. Keepalived helps ensure the entry point is always active. Ultimately, the goal is robust systems where services themselves sync and run behind layers of failover, but Keepalived is a key piece of that puzzle for managing the IP addresses.

A small server cabinet rack filled with networking and computing equipment.A small server cabinet rack filled with networking and computing equipment.

Speaking of remote access, there are several options beyond traditional VPNs. Should you use Tailscale, Pangolin, ZeroTier, or NetBird to remotely access your home lab?

Smoother Proxmox Cluster Management

Setting up a high-availability Proxmox cluster is great for keeping your VMs running even if a node goes down. But what about managing the cluster itself? If you need to log into a specific node for administration and that node is temporarily offline or having network issues, you have to figure out which other node is active and connect to its specific IP address.

Using Keepalived to access the cluster with a single virtual IP streamlines this. Keepalived can monitor the Proxmox nodes and ensure the virtual IP always points to the currently active master node. This means I only ever need to remember one IP address to log into my cluster’s administration interface, and I’m guaranteed to reach a working node. It’s a small convenience, but one that saves time and frustration over the long haul.

Two physical servers configured as a Proxmox cluster for high availability.Two physical servers configured as a Proxmox cluster for high availability.

If you’re curious about setting one up, this is how you build a Proxmox cluster.

The Value of Keepalived

Keepalived is a powerful yet relatively simple tool for adding essential failover to your home lab or self-hosted services. It solves the “single point of failure” problem for network access by providing a virtual IP that guarantees connectivity to an active server.

While some platforms, like OPNsense firewalls which have built-in CARP (another VRRP implementation), offer native failover solutions, many self-hosted applications don’t. Keepalived fills that gap perfectly, helping me build a more robust and reliable home network where my services are always available when I need them.

Do you use Keepalived or other tools to keep your home lab services online? Share your experiences in the comments below!