When re-addressing a remote Linux host or Cumulus Linux switch in-band over SSH, deleting the primary IPv4 address immediately drops your session. By adding the new IP as a secondary address and enabling kernel promote_secondaries, the secondary IP seamlessly becomes primary when the old address is removed:
First you have to add a secondary IP address to the interface, and confirm like so:
ip addr add 192.168.1.10/24 dev eth0
ip addr show eth0eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 44:38:39:00:11:aa brd ff:ff:ff:ff:ff:ff
inet 192.168.1.5/24 scope global eth0
inet 192.168.1.10/24 scope global secondary eth0
Now we have to setup the interface to where it will promote the secondary IP address when we remove the first like so:
echo 1 > /proc/sys/net/ipv4/conf/eth0/promote_secondariesor
sysctl net.ipv4.conf.eth0.promote_secondaries=1** PRO-TIP: Change eth0 to all to have it work on all interfaces.
Lastly we need to remove the original IP address and confirm like so:
ip addr del 192.168.1.5/24 dev eth0
ip addr show dev eth0eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 44:38:39:00:11:aa brd ff:ff:ff:ff:ff:ff
inet 192.168.1.10/24 scope global eth0
The interface is now running on the new primary IPv4 address without dropping active TCP/SSH sessions.
Chaining
ifreload -ainside a detachednohup bash -c "..." &subshell is the gold standard for remote management IP migrations on Cumulus Linux when out-of-band console isn't reachable.Even better with NCLU/NVUE on newer Cumulus releases, but on 2.5/3.x editing
/etc/network/interfacesand triggeringifreload -ain the background is still the safest way not to saw off the branch you're sitting on.