Why keepalived is not performing a failover upon network restart?
Environment
- Red Hat Enterprise Linux(RHEL) 7.
- Keepalived (All Versions).
- NetworkManager-1.0.4-9.el7 and above.
Issue
- When
NetworkManageris running in the system and network restart is performed
Keepalivedis losingVIPKeepalivedis not performing afailover
Resolution
- When
NetworkManageris running in the system, it is NOT recommended to restartnetworkservice. - Use
ip linkto mark the interface link down and to verify thekeepalivedfailover.
# ip link set down dev <interface-name>
Root Cause
-
Keepalivedtracks the interfacelinkstatus and performs afailoverif thelinkgoesdown. -
When there is
NetworkManagerrunning in the system andnetworkservice stops, it does not mark the interfacelinkstatus down. Sokeepaliveddoes not perform afailover, aslinkstatus remains the same. -
However, when there is no NetworkManager and the network service stops, it marks the interface
linkstatusdown. As link goes down,keepaliveddetects it and performs the failover.
Diagnostic Steps
- When there is no
NetworkManagerandnetworkservice stops, it brings down the interface, removes the IPs and marks the interfacelinkstatusdown.
Interface status when network service is running :-
# ethtool ens3 | grep -i "link det"
Link detected: yes
# ip a s ens3
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:00:00:00:00:aa brd ff:ff:ff:ff:ff:ff
inet 10.0.0.1/24 brd 10.0.0.255 scope global dynamic ens3
valid_lft 3583sec preferred_lft 3583sec
inet 10.0.0.2/24 scope global secondary keepalived
valid_lft forever preferred_lft forever
# systemctl stop network
# ip a s ens3
2: ens3: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:00:00:00:00:aa brd ff:ff:ff:ff:ff:ff
# ethtool ens3 | grep -i "link det"
Link detected: no
- When there is
NetworkManagerand thenetworkservice stops, it brings down the interface, removes the IP butdoes not markthe interfacelinkstatusdown.
Interface status when network service is running :-
# ethtool ens3 | grep -i "link det"
Link detected: yes
# ip a s ens3
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:00:00:00:00:aa brd ff:ff:ff:ff:ff:ff
inet 10.0.0.1/24 brd 10.0.0.255 scope global dynamic ens3
valid_lft 3583sec preferred_lft 3583sec
inet 10.0.0.2/24 scope global secondary abc
valid_lft forever preferred_lft forever
# systemctl stop network
# ip a s ens3
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:00:00:00:00:aa brd ff:ff:ff:ff:ff:ff
# ethtool ens3 | grep -i "link det"
Link detected: yes
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments