2

I am in a situation where I need to set 2 VRRP instances on same interface. I need to achieve this because rsyslogd and elasticsearch needs to use interface eth0 for network communication.

This post seemed to be a similar one did not mention about the configuration so I decided to ask a question.

I created a configuration below but two masters are created on different host.

Master side configuration

vrrp_script chk_rsyslog {
  script "netstat -atunp | grep rsyslogd | grep '0.0.0.0:514' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}

vrrp_script chk_es {
  script "netstat -atunp | grep java | grep '192.168.21.14:9300' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK

vrrp_instance RH_1 {
    state MASTER
    interface eth0
    virtual_router_id 50
    priority 10
    advert_int 1
    virtual_ipaddress {
        192.168.11.250/24
    }

    track_script {
      chk_rsyslog
    }
}

vrrp_instance ES_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 10
    advert_int 1
    virtual_ipaddress {
        192.168.11.251/24
    }

    track_script {
      chk_es
    }
}

Backup side configuration

vrrp_script chk_rsyslog {
  script "netstat -atunp | grep rsyslogd | grep '0.0.0.0:514' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}

vrrp_script chk_es {
  script "netstat -atunp | grep java | grep '192.168.21.15:9300' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}

vrrp_instance RH_1 {
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 9
    advert_int 1
    virtual_ipaddress {
        192.168.11.250/24
    }

    track_script {
      chk_rsyslog
    }
}

vrrp_instance ES_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 9
    advert_int 1
    virtual_ipaddress {
        192.168.11.251/24
    }

    track_script {
      chk_es
    }
}

Log on the backup side shows both instances first starts up but ES_1 is not reflected to ip setting for os.

Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Netlink reflector reports IP 192.168.11.15 added
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Netlink reflector reports IP 192.168.21.15 added
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Netlink reflector reports IP fe80::ab04:d4e4:841e:e3e1 added
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Netlink reflector reports IP fe80::812:1dd8:9ed1:a6af added
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Registering Kernel netlink reflector
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Registering Kernel netlink command channel
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Registering gratuitous ARP shared channel
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Opening file '/etc/keepalived/keepalived.conf'.
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Configuration is using : 69267 Bytes
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Using LinkWatch kernel netlink reflector...
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: VRRP_Instance(RH_1) Entering BACKUP STATE
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: VRRP_Instance(ES_1) Entering BACKUP STATE
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]
Apr 19 08:49:54 rhel2 Keepalived_healthcheckers[23320]: Configuration is using : 7722 Bytes
Apr 19 08:49:54 rhel2 Keepalived_healthcheckers[23320]: Using LinkWatch kernel netlink reflector...
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: VRRP_Script(chk_rsyslog) succeeded
Apr 19 08:49:58 rhel2 Keepalived_vrrp[23321]: VRRP_Instance(RH_1) Transition to MASTER STATE

My ip addr command result.

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:12:0e:da brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.15/24 brd 192.168.11.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.11.250/24 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ab04:d4e4:841e:e3e1/64 scope link
       valid_lft forever preferred_lft forever

Is it possible to set multiple VRRP instances on same interface?

My platform information is below.

[root@rhel2 keepalived]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
[root@rhel2 keepalived]# rpm -qa | grep keepalived
keepalived-1.2.13-8.el7.x86_64
1

I did not have closing bracket '}' for chk_es

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.