Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I add two IPs like this:

  1. ip addr add dev eth2
  2. ip addr add dev eth2

and then I try to delete one of like this:

  1. ip addr del dev eth2

BOTH IPs will be deleted and I don't know how to handle it.

Any one knows how to solve it?

share|improve this question
up vote 1 down vote accepted

If you do ip addr list dev eth2 after your two add commands, you will see something like this (emphasis mine):

2: eth2:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
     link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
     inet brd scope global eth2
     inet scope global eth2
     inet scope global secondary eth2

The important part to notice is that Linux treats the second address as secondary to the first one, as they are in the same logical subnet (/24). Deleting the secondary address has no impact on the primary one, but vice versa.

If you need to add/del addresses in, you probably should first add one address which is always valid (e.g. and then add and as secondary addresses. Then you can add/delete the .1 and .2 address at will.

If this is not possible, then you can also temporarily add before deleting This will maintain connectivity for all connections from outside your network. Depending on your network setup (i.e., whether your router supports proxy ARP), you may also be able to use temporarily.

share|improve this answer

Something else is likely doing things behind your back. NetworkManager is a known offender.

Run ip monitor while executing your commands, and see if someone else is modifying the configuration.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.