carp
Address Resolution Protocol redundancy
TLDR
Start a REPL (interactive shell)
Start a REPL with a custom prompt
Build a carp file
Build and run a file
Build a file with optimizations enabled
Transpile a file to C code
SYNOPSIS
carp <command> [arguments...]
carp configure <interface> vhid <id> [addr <ip/mask>] [options...]
carp status [<interface>]
carp {up|down} <interface>
PARAMETERS
interface
Specifies the network interface (e.g., eth0) to configure CARP on.
vhid id
Sets the Virtual Host ID (1-255) for the CARP group. This must be unique per group and shared across participating hosts.
addr ip/mask
Assigns the shared virtual IP address and its subnet mask (e.g., 192.168.1.1/24) to the CARP group. This is the address that fails over.
advbase seconds
Sets the base interval (in seconds) for CARP advertisement packets (default 1). These packets are used for master election and state synchronization.
advskew milliseconds
Adds an additional time (in milliseconds) to advbase. A lower skew value indicates a higher priority for becoming master, allowing you to bias election.
pass password
Sets the authentication password for the CARP group. This ensures only authorized hosts can participate and prevents spoofing of advertisements.
status [interface]
Displays the current CARP state (master/backup) and configuration for a specified interface or all CARP-enabled interfaces.
up
Activates the CARP interface, allowing it to participate in master election and advertise its state.
down
Deactivates the CARP interface, withdrawing it from the CARP group and releasing the virtual IP.
DESCRIPTION
CARP (Common Address Redundancy Protocol) is a network protocol designed to provide redundancy and failover for IP addresses, ensuring high availability of network services. It allows multiple hosts on the same segment to share a set of IP addresses. In the event of a primary host failure, a backup host seamlessly takes over the IP addresses, maintaining service continuity.
While CARP originated and is natively supported on OpenBSD, a dedicated carp command as a user-space utility does not exist on standard Linux distributions. Linux typically achieves similar high-availability functionality through VRRP (Virtual Router Redundancy Protocol) implementations, most notably via the keepalived daemon, or by configuring network interfaces and kernel parameters using tools like ip and sysctl.
This analysis describes the functionality a carp command would expose if it existed as a direct Linux utility for managing CARP protocol states, reflecting its common use-cases.
CAVEATS
It is crucial to note that a direct, dedicated carp command does not exist as a standard utility on typical Linux distributions. While the CARP protocol itself exists and is used in network architectures, its management on Linux is usually achieved through other means:
- Virtual Router Redundancy Protocol (VRRP): Linux commonly uses VRRP, implemented by daemons like keepalived, to achieve similar high-availability functionality.
- Standard Networking Tools: IP address configuration and routing on Linux are handled by the ip command (from iproute2) and network interface configuration files.
- Kernel Parameters: CARP-related kernel tunables, if present (though often specific to BSDs), would be managed via sysctl.
LINUX EQUIVALENTS
On Linux, the functionality provided by CARP is typically achieved using the Virtual Router Redundancy Protocol (VRRP). The most popular open-source software implementing VRRP for Linux is keepalived. It integrates with ipvsadm for load balancing and provides robust health checking mechanisms to ensure high availability. While the protocols differ in some technical details and origins, both aim to provide seamless failover for shared IP addresses.
CARP PROTOCOL DETAILS
CARP operates by sending advertisement packets to multicast addresses. A master host is elected based on configured parameters like advbase (advertisement base interval) and advskew (skew time). The host with the lowest combined advbase + advskew becomes the master. It supports IPsec authentication for securing advertisement packets using a shared password, preventing unauthorized takeover of the virtual IP address. CARP uses a Virtual Host ID (VHID) to group multiple physical hosts sharing the same virtual IP address.
HISTORY
CARP was developed by OpenBSD as a free, open alternative to proprietary router redundancy protocols like VRRP and HSRP, addressing concerns about patent infringement and licensing. It was designed to provide robust and secure IP address failover within local area networks. While its native implementation is a core part of OpenBSD's networking stack, the principles of CARP have influenced high-availability solutions across other operating systems. On Linux, similar functionalities are predominantly fulfilled by VRRP implementations (e.g., keepalived), which were already well-established before CARP's widespread adoption.