You are here: Home / Debian GNU/Linux / Servers / Various / Setup a failover IP with heartbeat on Debian

Setup a failover IP with heartbeat on Debian

by Pierre-Yves Landuré last modified Nov 08, 2017 02:53 provide a fail-over IP functionality for Dedibox servers. This functionality can be configured by a REST interface. This howto setup a REST client for the high-availability cluster software Heartbeat allowing to change fail-over IP destination when a member of the cluster crash.

This howto is tested on:

  • Debian 7.0 Wheezy


This howto needs:


Provide the REST API authentication key (available in the API page of console):


Provide the name of the network interface linked to the failover IP:


Provide the failover IP address assigned to the cluster:



Detect the destination IP address of the failover IP:

NET_IP="$(command ifconfig "${NET_DEV}" \
  | command grep 'inet ' \
| command sed -e 's/^.*inet [^:]*:\([^ ]*\) .*$/\1/')"

Environment preparation

Install the needed software:

command apt-get install curl

Download the Heartbeat resource script:

command wget '' \
    --quiet --no-check-certificate --output-document='/etc/ha.d/resource.d/OnlineFailoverIP'
command chmod +x '/etc/ha.d/resource.d/OnlineFailoverIP'


Configure Heartbeat:

command sed -i \
    -e "s/${FAILOVER_IP}.*$/& OnlineFailoverIP::${API_TOKEN}::${FAILOVER_IP}::${NET_IP}/" \

Reload Heartbeat configuration:

service heartbeat reload