-->
🏠 🔍
SHAREOLITE

Using Keepalived for IP failover in Linux


We reviewed "KeepAlived" - IP failover package which has VRRP stack direct IP failover on a Redhat Linux RHEL operating system. Below  is a summary and review of this method -
 



Our test setup
  • Server A , Main IP - 192.10.0.173
  • Server B , Main IP - 192.10.0.49
  • Virtual / floating IPs - 192.10.0.193,192.10.0.194  
How to install 
  • Downloaded the latest keepalived package from their website - http://www.keepalived.org/download.html - this comes default with our operating system DVD also as RPMs.
  • tar -zxvf keepalived-1.2.12.tar.gz
  • cd keepalived-1.2.12
  • ./configure
  • make
  • make install
  • Above commands executed in both server A and B as root user.
Configuration files

  • /usr/local/etc/keepalived/keepalived.conf
  • Priority parameter decides the master server holding the VIPs based on voting mechanism.  Higher the value - greater the priority. Server A has high priority
  • interface parameter decides on which interface the virtual IPs should bind.
  • virtual_ipaddress parameter - one or more virtual IPs can be configured.
  • More information on each parameter will be present in their man page - doc/man/man5/keepalived.conf.5

Server A configuration - /usr/local/etc/keepalived/keepalived.conf 

! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id A
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 1
    priority 150
    garp_master_delay 5
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
    192.10.0.193
    192.10.0.194
    }

}

Server B configuration - /usr/local/etc/keepalived/keepalived.conf 

! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id B
}

vrrp_instance VI_1 {
    state BACKUP
    interface br0
    virtual_router_id 1
    priority 100
    garp_master_delay 5
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.10.0.193
        192.10.0.194
    }
}

Starting and Stopping the service
  • /usr/local/sbin/keepalived -f /usr/local/etc/keepalived/keepalived.conf -D -d     , where -f is the config file , -D & -d are for debug logs
  • All logs are written to /var/log/messages and current status can be tracked easily using tshark / tcpdump -   tcpdump -i any -R vrrp
  • To shutdown , ps -ef |grep keepalive  , get the PID and kill it.
  • Alternately this can be configured as a service under /etc/init.d and started as service keepalived stop and stopped as service keepalived stop
  • Use , ip addr show command to view the VIP port mapping details.
Hope this is useful to some keepalived beginners.

tshark examples command line protocol analyzer

T-Shark , is the free command line network protocol analyzer from popular wire shark community which lets us capture packet data from a live network. Below are few examples to illustrate its usage. Hope it is useful to some Linux command line protocol analyzer newbies.
  • As an online Short message peer to peer (SMPP) protocol analyzer
Command  : tshark -i any -R "smpp and ip.dst==192.168.7.6" -T text -V -x -c 1000


where -i any indicates any ethernet port , -R is the filter ( in this example captures all SMPP packets towards IP 192.168.7.6) , -T text is for human readable format , -V for long format , -x for Hex dump and -c 1000 , stops after first 1000 packets.


  • For simple HTTP / XML traffic checks

Command : tshark tcp port 80 or tcp port 443 -V -R "http.request || http.response"   


  • Selecting required fields from a offline file and generate a CSV file.

Command : tshark -t ad -r pdu.pcap -R "smpp" -T fields -e frame.time -e smpp.sequence_number -e smpp.command_id  -e smpp.source_addr -e smpp.destination_addr -E separator='|'            


  • Rotating the files based on duration

Command : tshark -q -i any -w test.pcap -b duration:30 -b files:10           


  • GSM MAP protocol analyzer filter.

Command : tshark -i any -R "gsm_map" -T text -V -x -c 100      

Refer this link for more capture filters
http://www.wireshark.org/docs/dfref/

–>