3

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:

IPADDR_START=192.168.0.1
IPADDR_END=192.168.0.254

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]
netmask 255.255.255.0

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?

5
  • 11
    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. Jun 17, 2009 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. Jun 17, 2009 at 11:33
  • 1
    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? Jun 17, 2009 at 11:34
  • I'm guessing some sort of misguided NAT "solution" for "security".
    – womble
    Jun 17, 2009 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. Jun 17, 2009 at 12:40

1 Answer 1

5

Add a pile of up lines like so:

iface eth0 inet static
  address 192.168.0.1
  netmask 255.255.255.0
  up ip addr add 192.168.0.2/24 dev eth0
  up ip addr add 192.168.0.3/24 dev eth0
  up ip addr add 192.168.0.4/24 dev eth0
  up ip addr add 192.168.0.5/24 dev eth0
  ...
2
  • 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? Jun 17, 2009 at 11:31
  • 2
    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, 2009 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .