19.4.09

Ucarp. Virtual IP for Linux boxes

UCARP allows a couple of hosts to share common virtual IP addresses in order to provide automatic failover. UCARP is a portable implementation of the CARP protocol.

#Start script for first host

/usr/sbin/ucarp -B -z -P -b 1 --interface=eth0 --srcip=10.10.10.1 --vhid=1 --pass=zxcvbn --addr=10.10.10.10 --upscript=/etc/vip-up.sh --downscript=/etc/vip-down.sh

#Start script for second host

/usr/sbin/ucarp -z -B -b 2 -k 200 -r 4 --interface=eth0 --srcip=10.10.10.2--vhid=1 --pass=zxcvbn --addr=10.10.10.10 --upscript=/etc/vip-up.sh --downscript=/etc/vip-down.sh

-------------------------------------
Startup script /etc/vip-up.sh

#!/bin/bash
/sbin/ifconfig eth0:1 10.10.10.10/24 > /dev/null 2>&1

-------------------------------------
Shutdown script /etc/vip-down.sh

#!/bin/bash
/sbin/ifconfig eth0:1 down > /dev/null 2>&1

Make scripts executable

chmod 700 /etc/vip-up.sh
chmod 700 /etc/vip-down.sh
share on: facebook

No comments:

Post a Comment