Configure keepalived to send email on state change

You can configure keepalived to send email notifications of state changes; for example, when a system changes from a master to a backup state (or backup to master). To enable email notifications, you must enable the postfix service on the appliance and modify the keepalived configuration file on each system.

Enable postfix on the appliance

The postfix daemon is installed but disabled by default on the appliance.

To enable the appliance to send emails from keepalived, log in to the appliance as root and enter this command to start the postfix service:

# service postfix start

To start the postfix service automatically at boot time, enter this command:

# chkconfig postfix on

Enable email notifications in the keepalived configuration file

To enable email notifications, modify the keepalived configuration file on each system as follows:

  1. Add the following section to the configuration file:
  2. global_defs {
       # addresses here are destinations for emails from the server
       notification_email {
       # For clarity it is suggested that the from address
       # given here is different on each server in the cluster
       smtp_connect_timeout 30
       # System identifier for subject of email
       router_id Appliance_hostname-or-IP_address
Note   Modify the values to suit your own environment. The router_id and notification_email_from sections must be unique for each server in a cluster.
  1. Add the line smtp_alert to the vrrp_instance section of the configuration file:
  2. vrrp_instance VI_1 {
        state MASTER
        interface eth0
        virtual_router_id 5
        priority 10
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass 12345678
        virtual_ipaddress {

        track_script {

  3. Restart keepalived to load the configuration changes:
  4. # service keepalived restart

Related Links