Change Linux (Cumulus) IP address without losing connectivity

I was having some problems with cumulus, I needed to change an IP address of an interface without loosing connectivity, so I had to do the following:

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 eth0
eth0: <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_secondaries

or

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 eth0
eth0: <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

 

And we’re done, yay!!!