How do I configure a failover IP address on CentOS 7 ?

Linode Staff

I'm using two CentOS 7 servers and I'd like to configure a failover IP for high availability. I can see that this option is provided in the Remote Access tab but I'm not sure how to handle the failover process internally on the server. How would I automate the process?

1 Reply

KeepaliveD is a great program for configuring IP failover on a Linux server. There is a section in one of the Linode High Availability guides for how to configure KeepaliveD in a cluster:

If you just want to configure Keepalive between hosts I believe you can use the same general configuration settings with a few tweaks.

  • On the primary Linode obtain an additional floating IPv4 by opening a ticket with the Linode support team.

  • Navigate to the Remote Access tab on the secondary linode and follow the link for IP Failover.

  • Select the newly obtained IPv4 address and save.

  • Install KeepaliveD on both servers:

yum install keepalived

  • Edit the following line in your /etc/sysconfig/keepalived file on all database nodes, adding -P to enable virtual router redundancy protocol:


  • Create a backup of the keepalived.conf file:

cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.backup

  • Replace the keepalived.conf with the following where is the failover IP and DO SOMETHING is your monitor check:
! Configuration File for keepalived
global_defs {
    notification_email {

    router_id LVS_DBCLUSTER

vrrp_script chk_pxc {
    script "DO SOMETHING"
    interval 15
    fall 4
    rise 2

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 50
    advert_int 1
    track_interface {
    track_script {
    authentication {
        auth_type PASS
        auth_pass example_password
    unicast_peer {

    virtual_ipaddress {
    notify_master "/bin/echo 'now master' > /tmp/keepalived.state"
    notify_backup "/bin/echo 'now backup' > /tmp/keepalived.state"
    notify_fault "/bin/echo 'now fault' > /tmp/keepalived.state"
  • Add the following entry to your firewall configuration, within the zones block:


    <protocol value="vrrp" />
    <accept />
  • Reload the firewall rules:

firewall-cmd --reload

  • Start the keepalived service and enable it to load at boot time:

systemctl start keepalived
systemctl enable keepalived


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct