Here's the quick and dirty on how I got CARP working. I got most of the info from a few sites I found with Google, but none of them laid it out as clearly as I'd have preferred.
This example uses two servers, carp1.domain.com and carp2.domain.com, each of which is capable of acting as server.domain.com (the persistent host.)
First, include the following device in the kernel config. Build and install the CARP-enabled kernel.
carp1.domain.com and carp2.domain.com are each capable of acting as server.domain.com. carp1 and carp2 are connected to the 192.168.10.0/24 network on bge0, and are connected to each other via crossover cable on the 192.168.20.0/24 network on bge1.
192.168.10.140 is server
192.168.10.141 is carp1
192.168.10.142 is carp2
In /etc/sysctl.conf add the line:
Make sure this sysctl is activated by issuing a command line directive as root:
Here are the important bits of the /etc/rc.conf file for carp1:
And here are the important bits of the /etc/rc.conf file for carp2:
Make sure that server.domain.com, carp1.domain.com and carp2.domain.com are set up in your DNS.
to enable carp use:
You should get some messages in /var/log/messages including lines like this:
Ping server.domain.com. Determine which of your CARP hosts is currently acting as the master, and unplug its ethernet cable. The ping should continue just fine as the other CARP machine assumes the duties of server.domain.com.
Enjoy.
This example uses two servers, carp1.domain.com and carp2.domain.com, each of which is capable of acting as server.domain.com (the persistent host.)
First, include the following device in the kernel config. Build and install the CARP-enabled kernel.
Code:
device carp
carp1.domain.com and carp2.domain.com are each capable of acting as server.domain.com. carp1 and carp2 are connected to the 192.168.10.0/24 network on bge0, and are connected to each other via crossover cable on the 192.168.20.0/24 network on bge1.
192.168.10.140 is server
192.168.10.141 is carp1
192.168.10.142 is carp2
In /etc/sysctl.conf add the line:
Code:
net.inet.carp.preempt=1
Make sure this sysctl is activated by issuing a command line directive as root:
% sysctl net.inet.carp.preempt=1
Here are the important bits of the /etc/rc.conf file for carp1:
Code:
hostname="carp1.domain.com"
ifconfig_bge0="inet 192.168.10.141 netmask 255.255.255.0"
ifconfig_bge1="inet 192.168.20.2 netmask 255.255.255.0"
defaultrouter="192.168.10.1"
cloned_interfaces="carp1 carp2"
ifconfig_carp1="vhid 10 advskew 50 pass PASSWORD1 192.168.10.140/24"
ifconfig_carp2="vhid 20 advskew 50 pass PASSWORD2 192.168.20.1/24"
And here are the important bits of the /etc/rc.conf file for carp2:
Code:
hostname="carp2.domain.com"
ifconfig_bge0="inet 192.168.10.142 netmask 255.255.255.0"
ifconfig_bge1="inet 192.168.20.3 netmask 255.255.255.0"
defaultrouter="192.168.10.1"
cloned_interfaces="carp1 carp2"
ifconfig_carp1="vhid 10 advskew 80 pass PASSWORD1 192.168.10.140/24"
ifconfig_carp2="vhid 20 advskew 80 pass PASSWORD2 192.168.20.1/24"
Make sure that server.domain.com, carp1.domain.com and carp2.domain.com are set up in your DNS.
to enable carp use:
% ifconfig carp1 up
% ifconfig carp2 up
You should get some messages in /var/log/messages including lines like this:
Code:
carp0: 2 link states coalesced
carp1: 2 link states coalesced
Ping server.domain.com. Determine which of your CARP hosts is currently acting as the master, and unplug its ethernet cable. The ping should continue just fine as the other CARP machine assumes the duties of server.domain.com.
Enjoy.