Leanpub Header

Skip to main content

Mastering Keepalived

High Availability, VRRP, Failover Architecture, Health Checking and Production Operations

Mastering Keepalived
This book is 100% completeLast updated on 2026-10-03

Mastering Keepalived is a practical guide to building reliable, highly available infrastructure with VRRP, failover and health checking. Learn how to design, configure, troubleshoot and secure Keepalived in real production environments, from core networking concepts to advanced HA architectures and day-to-day operations.

Minimum price

$25.00

$35.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
195
Pages
About

About

About the Book

This book is a comprehensive, production-oriented guide to Keepalived, the Linux routing daemon that implements the Virtual Router Redundancy Protocol and provides high-availability failover for networked services. It is written for system administrators, DevOps engineers, network engineers and site reliability engineers who need to design, implement, operate and troubleshoot Keepalived-based HA architectures in real environments. The text takes you from the networking fundamentals through VRRP protocol mechanics, into detailed configuration of every major Keepalived feature and culminates in advanced architecture patterns, failure mode analysis, troubleshooting methodology, security hardening and production operations. All examples are complete and functional, all configuration directives are verified against current documentation and all architectural guidance is grounded in the realities of operating resilient infrastructure.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

High Availability, VRRP, Failover Architecture, Health Checking and Production Operations

Introduction

  1. What this book covers
  2. Prerequisites and scope
  3. Conventions and naming

Chapter 1: High Availability Foundations

  1. The fundamental problem: the single address
  2. What high availability actually means
  3. The VIP pattern
  4. Where Keepalived fits
  5. The shared-nothing constraint
  6. Understanding failure domains in HA pairs
  7. The role of time in high availability
  8. Summary

Chapter 2: Linux Networking Prerequisites

  1. Interface addressing: primary, secondary, labels
  2. The iproute2 suite
  3. Routing tables and policy routing
  4. ARP: the mechanism that makes VIPs work
  5. IPv6 and Neighbor Discovery
  6. Interface bonding and HA
  7. VLANs and virtual interfaces
  8. Network namespaces
  9. Sysctl parameters that affect HA behavior
  10. Multicast and IGMP
  11. Summary

Chapter 3: VRRP Protocol Deep Dive

  1. Protocol history and RFC evolution
  2. The virtual router abstraction
  3. Master and Backup roles
  4. Priority and election
  5. Advertisements and heartbeat
  6. Master_Down_Timer and failure detection
  7. Preemption
  8. State machine and transitions
  9. Unicast mode
  10. Virtual MAC addresses
  11. Authentication and security
  12. Accept mode and packet reception
  13. Timer interactions and convergence
  14. Summary

Chapter 4: Keepalived Architecture and Design

  1. Project origins and evolution
  2. The process model
  3. Configuration parsing
  4. I/O multiplexing and event handling
  5. Netlink and kernel communication
  6. Signal handling
  7. Memory management
  8. Threading model and concurrency
  9. Interaction with iproute2 and other tools
  10. Debugging support
  11. Summary

Chapter 5: Installation and Deployment

  1. Version awareness
  2. Package installation on Debian and Ubuntu
  3. Package installation on RHEL, AlmaLinux, Rocky Linux
  4. Package installation on SUSE/openSUSE
  5. Package installation on Alpine Linux
  6. Building from source
  7. Service management with systemd
  8. SELinux and AppArmor considerations
  9. Initial configuration validation
  10. Upgrade procedures
  11. Summary

Chapter 6: Configuration Fundamentals

  1. Configuration file location and structure
  2. The global_defs block
  3. Including external files
  4. Configuration validation
  5. Reloading vs restarting
  6. Common configuration mistakes
  7. Best practices for maintainable configurations
  8. Summary

Chapter 7: VRRP Instances: Core Configuration

  1. The minimal vrrp_instance
  2. state: MASTER or BACKUP
  3. interface: binding to a network interface
  4. virtual_router_id: the group identifier
  5. priority: determining the master
  6. advert_int: advertisement interval
  7. nopreempt vs preempt
  8. Authentication
  9. Gratuitous ARP configuration
  10. accept and no_accept
  11. version: VRRP protocol version
  12. A complete two-node example
  13. Summary

Chapter 8: Virtual IP Addresses, Routes and Rules

  1. virtual_ipaddress: basic VIP configuration
  2. Multiple VIPs
  3. virtual_ipaddress_excluded: the excluded pool
  4. virtual_ipaddress_dev: binding VIPs to specific interfaces
  5. Virtual routes
  6. Virtual rules
  7. How Keepalived programs the kernel
  8. IPv6 virtual addresses
  9. IP conflict behavior
  10. Common mistakes
  11. Summary

Chapter 9: Interface Tracking and Weighted Priorities

  1. How interface tracking works
  2. Weight semantics
  3. Multiple tracked interfaces
  4. Cumulative weight math
  5. Interface tracking vs script tracking
  6. Weight reverse
  7. When NOT to use interface tracking
  8. Multi-homed server example
  9. Bonded interface tracking
  10. Synchronization group tracking
  11. Summary

Chapter 10: Health Checking: Scripts and Process Monitoring

  1. vrrp_script: custom health checks
  2. Designing effective health checks
  3. Script example: checking a web server
  4. Script example: checking HAProxy
  5. Script permissions and security
  6. Script execution performance
  7. Script security: injection and environment
  8. vrrp_track_process: process monitoring
  9. Combining process and script tracking
  10. Fall, rise and stability
  11. Summary

Chapter 11: Notifications, Logging and State Changes

  1. Notification scripts: when they fire
  2. The notify catch-all
  3. Notification scripts in sync groups
  4. Logging with syslog
  5. Debug levels
  6. Structured JSON state dump
  7. Log message taxonomy
  8. Designing notification scripts
  9. Integration with monitoring systems
  10. Summary

Chapter 12: VRRP Synchronization and Grouping

  1. What synchronization groups do
  2. Configuring a sync group
  3. How synchronization works
  4. When to use synchronization groups
  5. Sync group notifications
  6. Weighted tracking in sync groups
  7. The global_tracking flag
  8. Example: load balancer pair
  9. Summary

Chapter 13: Multi-VIP and Active/Active Architectures

  1. True active/passive vs active/active
  2. Multiple VRRP instances on two nodes
  3. Service affinity with multiple VIPs
  4. Scaling: many VIPs across two nodes
  5. DNS round-robin with Keepalived
  6. Synchronization in active/active
  7. Weighted priorities for graceful degradation
  8. How many VIPs is too many?
  9. Summary

Chapter 14: Real-World HA Architectures: Common Patterns

  1. Pattern 1: simple two-node active/standby web server
  2. Pattern 2: highly available reverse proxy
  3. Pattern 3: highly available load balancer (HAProxy pair)
  4. Pattern 4: highly available API gateway
  5. Pattern 5: database connection router
  6. Common requirements across patterns
  7. Summary

Chapter 15: Advanced Architectures and Complex Environments

  1. Multi-tier architectures
  2. VLANs and Keepalived
  3. Bonded interfaces and Keepalived
  4. Virtual machines
  5. Network namespaces
  6. Containers and Keepalived
  7. Public cloud considerations
  8. Summary

Chapter 16: Failure Modes, Pathologies and Split-Brain

  1. Split brain: dual master
  2. Asymmetric connectivity
  3. Priority misconfiguration
  4. Preemption problems
  5. Health check false positives and false negatives
  6. Interface flapping
  7. Stale ARP and neighbor information
  8. Duplicate VIPs from misconfiguration
  9. Firewall blocking VRRP traffic
  10. Script execution failures
  11. Routing inconsistencies after failover
  12. Virtualization-related issues
  13. Cloud networking limitations
  14. Summary

Chapter 17: Troubleshooting Methodology and Diagnosis

  1. The troubleshooting mindset
  2. Step 1: check Keepalived process status
  3. Step 2: check VRRP state
  4. Step 3: check VRRP advertisements with tcpdump
  5. Step 4: check ARP and neighbor state
  6. Step 5: check health check scripts
  7. Step 6: check interface state
  8. Step 7: check routing
  9. Step 8: check firewall rules
  10. Step 9: check for split brain
  11. Step 10: check configuration syntax
  12. Common problems and their diagnostic signatures
  13. Distinguishing Keepalived issues from network or application issues
  14. Summary

Chapter 18: Observability, Monitoring and Alerting

  1. Key metrics to monitor
  2. Using keepalived_exporter with Prometheus
  3. Alerting on VRRP state changes
  4. Monitoring VIP reachability
  5. Log-based monitoring
  6. Grafana dashboards
  7. Alerting philosophy
  8. Integration with incident response
  9. Summary

Chapter 19: Security Hardening

  1. VRRP protocol security
  2. Script execution security
  3. Shell script injection risks
  4. File permissions
  5. SELinux and AppArmor
  6. Firewall configuration
  7. Network segmentation
  8. Monitoring for anomalies
  9. Secure upgrade procedures
  10. Summary

Chapter 20: Performance, Scalability and Operational Limits

  1. Resource usage
  2. Many VIPs
  3. Many VRRP instances
  4. Health check overhead
  5. Network traffic
  6. Failover convergence time
  7. System-level limits
  8. Bottlenecks
  9. Empirical guidance
  10. Summary

Chapter 21: Production Operations: Runbooks, Upgrades, Maintenance

  1. Configuration validation before changes
  2. Controlled failover for maintenance
  3. Upgrading Keepalived
  4. Changing VIPs
  5. Adding or removing nodes
  6. Configuration drift detection
  7. Backup and recovery
  8. Post-incident review practices
  9. Summary

Chapter 22: Production Reference

  1. Quick command reference
  2. Minimal two-node configuration template
  3. Health check script template
  4. Notification script template
  5. Firewall rules template
  6. Default values
  7. Troubleshooting decision tree
  8. Controlled failover procedure
  9. Security checklist
  10. Version compatibility notes
  11. Useful log patterns

Conclusion

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub