The cart is empty

Before you begin, ensure you have:

  • Two or more CentOS 7 systems prepared for configuration as VRRP routers.
  • Network configuration allowing communication between these systems.
  • Superuser (root) privileges on each system.

Installation and Configuration of Keepalived

Keepalived is software that implements VRRP on Linux. To install Keepalived, use the following command:

yum install keepalived

After installation, you need to create the configuration file keepalived.conf, typically located in /etc/keepalived/.

Configuring the Master Router

On the master router, open the file /etc/keepalived/keepalived.conf and add the following configuration:

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.10
    }
}

Here:

  • state MASTER indicates that this router will be the primary router.
  • interface eth0 specifies the network interface to be used.
  • virtual_router_id is the identifier of the VRRP instance. It must be unique within the shared network.
  • priority determines the router's priority. A higher value means a higher priority.
  • virtual_ipaddress defines the virtual IP address to be shared among routers.

Configuring the Backup Router

On the backup router, perform a similar configuration but with the state changed to BACKUP and a lower priority set:

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.10
    }
}

Starting and Testing

After completing the configuration on both routers, start Keepalived:

systemctl start keepalived

To ensure automatic startup of Keepalived on system boot, use:

systemctl enable keepalived

To verify the functionality of VRRP, you can turn off the Keepalived service or the network interface on the primary router and observe whether the backup router automatically takes over the active router role.

 

VRRP and Keepalived provide an effective solution for ensuring high availability of network services by enabling quick and automatic response to router failure. Configuring VRRP on CentOS 7 requires careful planning and testing, but the result is a robust network infrastructure capable of withstanding service interruptions caused by hardware or software failures.