Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

With ifconfig we can change the netmask with the folowing:

ifconfig eth0 netmask <new netmask>

How can we do this with the command ip?

I know ifconfig is deprecated and this mostly why I would like to do it the iproute2 way.

My objective is to extend our current network from a /24 to a /21 on-the-fly without disturbing services running on our servers. As a workaround currently I simply add a new route to the /21 and eventually a planned network restart will officialize the change. It works but I was wondering if there is a better way.


share|improve this question
up vote 5 down vote accepted

How about:

ip address add dev <device>
ip address del dev <device>

(Where is your current IP). ip address show Will list all of the assigned addresses.

share|improve this answer
Wow this works. I though I tried it with a resulting error problably a mistake. And this is better then ifconfig conterpart, with the ifconfig solution routes were dropped. – NastyTux May 11 '11 at 15:08
Yeah, I'm still amazed by how powerful ip is. Also you get to shorten most of the keywords to two or three characters, which makes you look like a ninja when someone is watching you type. :) – SmallClanger May 11 '11 at 15:24
Is this really the supposed way to do it? When I try this with ipv6 addresses I get "RTNETLINK answers: File exists" – rudimeier Jul 8 '13 at 16:10

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.