在接口上没有 IP 的情况下启动 keepalived?

Pau*_*aul 4 linux vrrp keepalived

我想在某个接口上使用 keepalived,该接口将在某个时候获得 IP 但最初没有 IP,我可以在配置中以某种方式设置它吗?如果我现在尝试启动它,keepalived 会出错,因为 keepalived 不知道在发送 VRRP 数据包时要使用哪个源 IP 地址。会议:

!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
}
Run Code Online (Sandbox Code Playgroud)

日志:

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 
Run Code Online (Sandbox Code Playgroud)

Pau*_*aul 5

新版本的keepalived2.0.5今天发布,它支持尚不存在的接口。碰巧也解决了我的问题,因为FAULT如果接口没有 IP,keepalived 将在一个状态下启动,这很好。只需添加dynamic_interfacesglobal_defs它就可以了。