Remove IP with ip command in linux

This happens because you use /24 network mask when delete. It is applied to address you input. Try the following:

ip addr del 1.1.1.2/32 dev eth2

The /32 mask defines exactly one host.


Deleting a primary IP address from an interface will, by default, delete all other address on the same subnet.

This is a reply to a REHL bug 1136733 reported by the user lain who provided an answer on 12-Mar-13 ...

You're adding multiple addresses in the same subnet, thus the second and subsequent ones become secondaries. This can be seen in the "ip addr show" output, note the keyword "secondary" next to those addresses.

By default, when deleting a primary address, kernel deletes also all respective secondaries.

If you want one of the secondaries to be promoted to be a new primary on primary deletion, set the net.ipv4.conf.eth9.promote_secondaries sysctl.


I don't have an eth2 to check this on but it works correctly on eth0 and I see no reason why eth2 should be magical. I presume you're using ip addr show dev eth2 as ifconfig eth2 doesn't appear to show the additional addresses added by ip.

One thing I have noticed is that the order you create/delete the addresses is important. The second and subsequent addresses added within the same network will be deleted if the primary address is deleted. Consider ...

    inet 1.1.1.1/24 scope global eth0
    inet 1.1.2.3/24 scope global eth0
    inet 1.1.1.2/24 scope global secondary eth0
    inet 1.1.1.3/24 scope global secondary eth0

If you delete 1.1.1.1 then the 1.2 and 1.3 addresses will be deleted too. If you delete any other address then only that address will be deleted.