…or better, they should not disappear at all.

If you use more than one IP address in the same CIDR network on your Linux box, you may have noticed, that some addresses are labeled as ‘secondary’.

inet brd scope global eth0
inet scope global secondary eth0
inet scope global secondary eth0

Outgoing traffic is routed through the primary IP address and the secondaries are ready to receive traffic. But if you remove the primary IP address, all secondary addresses are purged by default as well. This behavior is a little bit annoying and for most of us unexpected.

One workaround would be to change the netmask to /32 for the secondary addresses, but that's just a workaround and will leave you with a somewhat unclean network setup.

It is better to reconfigure your kernel (since ~2.6.12) to promote secondaries, if a primary address is removed. Just do

echo 1 > /proc/sys/net/ipv4/conf/all/promote_secondaries


sysctl net.ipv4.conf.all.promote_secondaries=1

and on all devices secondaries get promoted, you can also promote only on a specific device e.g. eth0 instead of all.

To change this persistently add the following file

# /etc/sysctl.d/10-network-promote_secondaries.conf

or if you do not have a /etc/sysctl.d directory, just add the line to your /etc/sysctl.conf.