Wednesday, June 9, 2010

Installing and running UCARP on Solaris

I was surprised to see that there was not much documentation on how to install and run UCARP on a Solaris machine. I found a couple of blogs listing the startup and shutdown scripts but didn't mention about how to run UCARP itself. I am documenting about how to install and run it, for details on CARP and UCARP refer OpenBSD faq page and UCARP official website respectively.

UCARP has a dependency on libpcap, so you need to install the libpcap from here before trying to install ucarp itself. Else you will see errors like ucarp.h:63:18: pcap.h: No such file or directory while installing.

Use version 1.5.1 or earlier, 1.5.2 has linking issues and wouldn't compile. Once compiled and installed, running UCARP should be easy, all you have to do is create two simple scripts to bring up the interface and shutdown the interface.

Listing if_up.sh:
----------------------------------
#!/bin/sh

ifconfig e1000g0:1 192.168.1.102 netmask 255.255.255.0
ifconfig e1000g0:1 up
----------------------------------

Listing if_down.sh:
----------------------------------
#!/bin/sh

ifconfig e1000g0:1 down unplumb
----------------------------------

Make the scripts executable, also you can find more generic scripts here. The ip 192.168.1.102 is the virtual ip address shared by both the machines. Once the scripts are setup run the below command on both the machines on which you want to setup UCARP.

Machine 1 whose ip is 192.168.1.81:

/opt/ucarp1.5/sbin/ucarp --interface=e1000g0 --srcip=192.168.1.81 --vhid=42 \
--pass=word --preempt --neutral --addr=192.168.1.102 \
--upscript=/etc/ucarp/if_up.sh --downscript=/etc/ucarp/if_down.sh --shutdown &

Machine 2 whose ip is 192.168.1.82:

/opt/ucarp1.5/sbin/ucarp --interface=e1000g0 --srcip=192.168.1.82 --vhid=42 \
--pass=word --preempt --neutral --addr=192.168.1.102 \
--upscript=/etc/ucarp/if_up.sh --downscript=/etc/ucarp/if_down.sh --shutdown &


This should be it. Note that the long options are somewhat necessary, since the shorter version of the options cause core dump.