Install and configure CARP/UCARP to UNIX/Linux servers with Python script

Usually, a Virtual IP is used to distribute the workload automatically among cluster nodes. Cisco uses HSRP to combine their routers in the Standby group with a single VIP assigned, which stands for the default gateway in a network. FreeBSD and Linux (Ubuntu, CentOS6, and Centos7) operating systems use CARP and UCARP respectively for this purpose.

The python script configures CARP for FreeBSD and UCARP for Linux machines automatically. While running from a CLI, please input the following data:

  • IP addresses for Master and Slave machines
  • Username and password for a superuser (root)
  • Virtual IP address
  • Preshared key to encrypt CARP/UCARP command flow

The configuration of Master/Slave is possible only between similar operating system – FreeBSD/FreeBSD, Ubuntu/Ubuntu, CentOS6/CentOS6 or CentOS7/CentOS7. Determination of the type of operating system is performed automatically.

The test environment consists of Ubuntu, CentOS6, CentOS7, FreeBSD servers in which the CARP/UCARP will be configured. Each type of OS has 2 machines.


Only machines of one type of OS can be configured at a time.


Note: The python script uses fabric library which requires BASH to be installed on all FreeBSD machines. Please use the following commands:

# pkg install -y bash
# echo "fdesc /dev/fd fdescfs rw 0 0" >> /etc/fstab ; mount -a
# chsh -s bash root ; cp /usr/local/bin/bash /bin/

Execute script to configure servers.









You can test the system by shutting down the master node while pinging the VIP. Only one ping should be lost.


If you try to use different types of operation systems for master and slave nodes, you will get the following notification and script will not perform the installation.
Try with FreeBSD and Ubuntu servers:


Try with Ubuntu and CentOS6 server:


Try with CentOS6 and CentOS7 server:


Use the following commands to download and execute code files:

# git clone
# cd carp-ucarp-unix-linux
# ./


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s