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

在没有接口 IP 的情况下启动 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
}

日志:

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 

答案1

今天发布了新版 keepalived 2.0.5,它支持尚不存在的接口。碰巧这也解决了我的问题,因为FAULT如果接口没有 IP,keepalived 将在某种状态下启动,这很棒。只需添加dynamic_interfaces它就global_defs可以了。

答案2

为什么不直接使用 ifconfig 给它一个临时地址呢?

相关内容