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

We have a client who needs to set up 2 Class C (/24) address ranges in Ubuntu. We have a single nic connected to the switch currently and the IPs are set up at the switch.

We have done this many times in RedHat based systems by using the IPADDR_START and IPADDR_END options in the ifcfg file such as this:


However this does not appear to be an option in Ubuntu. You have to set them up individually like so:

auto eth0:x
iface eth0:x inet static
address [IP ADDRESS]

Which is fine to shell script the creation of this file. But, I understand 'x' can only go up to 256 which would only allow one class C.

Does anyone know how we can add multiple class C ips to a single nic?

share|improve this question
First off, classful routing is dead. There is no such thing as a class C network any more. You're looking to add multiple /24 networks. I'm not entirely sure what you're trying to do. It would appear that you're trying to add every single IP address in a network to a single interface. Can you explain your requirements a little clearer. – David Pashley Jun 17 '09 at 11:07
That is correct - trying to add every IP address in 2 x /24s to the network interface. We have 2 nics on the system but would like to do this over eth0 if possible. – Dave Drager Jun 17 '09 at 11:33
If you are wanting the machine to respond to all those addresses for routing purposes then you probably want to look at bridging instead. If it is something like a web server doing address based multiple hosting, then could you instead consider name-based hosting instead of needing that many addresses? – David Spillett Jun 17 '09 at 11:34
I'm guessing some sort of misguided NAT "solution" for "security". – womble Jun 17 '09 at 11:42
This is for a client, my guess is either for websites or email (I am hoping for web, the only way I could see this used for email is for spammers). We don't poke into their business as long as they conform to our AUP. – Dave Drager Jun 17 '09 at 12:40
up vote 4 down vote accepted

Add a pile of up lines like so:

iface eth0 inet static
  up ip addr add dev eth0
  up ip addr add dev eth0
  up ip addr add dev eth0
  up ip addr add dev eth0
share|improve this answer
Will this work with separate /24s? Or will I need to do a separate iface for eth0:1? And also just for clarification, do you know for sure if this will work for > 254 IP addresses? – Dave Drager Jun 17 '09 at 11:31
This will work for whatever addresses you want, and with as many addresses as you want. I've personally seen it with >400 addresses in production. – womble Jun 17 '09 at 11:42

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.