Failover Redundancy in Ubuntu 11.10
1. Install ucarp:
root@master:~# apt-get install ucarp
root@slave:~# apt-get install ucarp
2. For the primary (master) host change /etc/network/interfaces as follows:
# This file describes the network interfaces available on your system
root@master:~# apt-get install ucarp
root@slave:~# apt-get install ucarp
2. For the primary (master) host change /etc/network/interfaces as follows:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.130
address 192.168.1.130
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# The secondary network interface
auto eth1
# The secondary network interface
auto eth1
iface eth1 inet static
address 192.168.2.1
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
ucarp-vid 1
ucarp-vid 1
ucarp-vip 192.168.2.254
ucarp-password secret
ucarp-advskew 14
ucarp-advbase 1
ucarp-facility local1
ucarp-master yes
ucarp-upscript /usr/share/ucarp/vip-up
ucarp-downscript /usr/share/ucarp/vip-down
iface eth1:ucarp inet static
iface eth1:ucarp inet static
address 192.168.2.254
netmask 255.255.255.0
3. For the secondary (slave) host change /etc/network/interfaces as follows:
# This file describes the network interfaces available on your system
3. For the secondary (slave) host change /etc/network/interfaces as follows:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.130
address 192.168.1.130
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# The secondary network interface
auto eth1
# The secondary network interface
auto eth1
iface eth1 inet static
address 192.168.2.2
address 192.168.2.2
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
ucarp-vid 1
ucarp-vid 1
ucarp-vip 192.168.2.254
ucarp-password secret
ucarp-advskew 14
ucarp-advbase 1
ucarp-facility local1
ucarp-master no
ucarp-upscript /usr/share/ucarp/vip-up
ucarp-downscript /usr/share/ucarp/vip-down
iface eth1:ucarp inet static
address 192.168.2.254
netmask 255.255.255.0iface eth1:ucarp inet static
address 192.168.2.254
4. Add to the /etc/rc.local:
root@master:~# ucarp -i eth1 -s 192.168.2.1 -v 1 -p secret -a 192.168.2.254 -u /etc/vip-up.sh -d /etc/vip-down.sh -z -B
root@slave:~# ucarp -i eth1 -s 192.168.2.2 -v 1 -p secret -a 192.168.2.254 -u /etc/vip-up.sh -d /etc/vip-down.sh -z -B
5. To check if works correctly check ip addresses on the interfaces on both hosts:
ip addr show
The virtual ip assigned to the ucarp interface should be seen only on the master host.
Ping the virtual ip to check if it is reachable.
Shutdown the master and observe that the slave takes over and virtual ip now can be seen.
Again, ping the virtual ip.