UCARP on Debian 10

In this example I will show what is needed to create a UCARP fail-over IP on Debian 10. In this example my service is BIND9, but ofcourse you can change that to anything you require.

  • Run apt-get install ucarp
  • Edit interfaces via nano /etc/network/interfaces.
    Config should look somtething like this;
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
        ucarp-vid 11
        ucarp-password password01
        ucarp-advbase 1
        ucarp-advskew 0
        ucarp-master no

iface eth0:ucarp inet static
  • mkdir /opt/ucarp
  • cd /opt/ucarp
  • Create the following 3 files;

start-ucarp (Match eth0, IPs and password to your situation)

/usr/sbin/ucarp -i eth0 -s -B -z -v 1 -p password01 -a -u /opt/ucarp/vip-up -z -d /opt/ucarp/vip-down

vip-up (Match /24 to your subnet)

/sbin/ip addr add ${2}/24 dev $1

vip-down (Match /24 and eth0 to your situation)

/sbin/arptables -I INPUT -d $2 -j DROP
/bin/sleep 2 && /sbin/ip addr del $2/24 dev eth0
/sbin/arptables -D INPUT 1
  • Make all the files executable using: chmod +x /opt/ucarp/*
  • Create a service for ucarp using:
    nano /etc/systemd/system/ucarp.service
    that should look like this;
Description=ucarp Virtual IP Address Management

ExecStop=/usr/bin/killall -SIGTERM ucarp
ExecStop=/bin/sleep 10

  • systemctl daemon-reload
  • systemctl enable ucarp.service
  • Reboot the system for the settings to take effect.

You should be able to run service ucarp status to see the effect of the settings and also the current state of the machine;

Mar 03 13:58:57 dns02 systemd[1]: Started ucarp Virtual IP Address Management.
Mar 03 13:58:57 dns02 ucarp[356]: [INFO] Local advertised ethernet address is [00:11:22:33:44:55] 
Mar 03 13:58:57 dns02 ucarp[356]: [WARNING] Switching to state: BACKUP 
Mar 03 13:58:57 dns02 ucarp[356]: [WARNING] Spawning [/opt/ucarp/vip-down 

Leave a Reply

Your email address will not be published. Required fields are marked *