5

I want to use keepalived on an interface that will get an IP at some point but will not have one initially, can I set this up somehow in the config? If I try to start it now keepalived errors out as keepalived doesn't know what source IP address to use when sending VRRP packets. Conf:

! Configuration File for keepalived

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 150
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass pwd
    }
    virtual_ipaddress {
       192.168.0.13
    }
    notify /etc/state_change.py
}

Log:

keepalived -f /etc/keepalived.conf --log-console --dont-fork  
Thu Jun 28 11:25:53 2018: Starting Keepalived v1.4.4 (05/08,2018)               
Thu Jun 28 11:25:53 2018: Running on Linux 4.7.8 #9 SMP Wed Jun 27 17:25:18 IST 
2018 (built for Linux 4.7.8)                                                    
Thu Jun 28 11:25:53 2018: Opening file '/etc/keepalived.conf'.                  
Thu Jun 28 11:25:53 2018: Starting Healthcheck child process, pid=18886         
Thu Jun 28 11:25:53 2018: Starting VRRP child process, pid=18887                
Thu Jun 28 11:25:53 2018: Opening file '/etc/keepalived.conf'.                  
Thu Jun 28 11:25:53 2018: Registering Kernel netlink reflector                  
Thu Jun 28 11:25:53 2018: Registering Kernel netlink command channel            
Thu Jun 28 11:25:53 2018: Registering gratuitous ARP shared channel             
Thu Jun 28 11:25:53 2018: Opening file '/etc/keepalived.conf'.                  
Thu Jun 28 11:25:53 2018: WARNING - default user 'keepalived_script' for script 
execution does not exist - please create.                                       
Thu Jun 28 11:25:53 2018: (VI_1): Cannot find an IP address to use for interface
 eth0                                                                           
Thu Jun 28 11:25:54 2018: Stopped                                               
Thu Jun 28 11:25:54 2018: Keepalived_vrrp exited with permanent error CONFIG. Te
rminating                                                                       
Thu Jun 28 11:25:54 2018: Stopping                                              
Thu Jun 28 11:25:54 2018: Stopped 
Paul
  • 253
  • 3
  • 8
  • What exactly do you expect keepalived to do if it can't send VRRP packets? – womble Jun 28 '18 at 23:54
  • @womble Be waiting and react when the interface gets an IP, then send the packets. Which it presumably already does when an interface loses an IP after initialization. – Paul Jun 29 '18 at 09:49

2 Answers2

6

The new version of keepalived 2.0.5 was released today and it supports interfaces that do not exist yet. By happenstance that also fixes my issue as keepalived will start in a FAULT state if the interface does not have an IP, which is great. Simply add dynamic_interfaces to global_defs and it works.

Paul
  • 253
  • 3
  • 8
1

Why not just give it a temporary address using ifconfig?

Jonas Bjork
  • 376
  • 1
  • 4
  • 1
    Hi Jonas, I can think of multiple always around this (and problems with each of them for the system we are using), I am wondering was my above question possible and I just don't know how to do it, before I explore them. – Paul Jun 28 '18 at 12:59