-9

Let's say that I have 1 network card and 2 blocks /24 of IP to assign:

150.50.50.0/24
150.60.60.0/24

I know, that I can only add 256 virtual interfaces to each NIC from http://www.liberiangeek.net/2012/04/create-virtual-network-adapters-in-ubuntu-12-04-precise-pangolin/

How I can add 2 blocks to same NIC? Should I use VLAN?

11
  • 5
    You can probably do this, but it probably is not what you actually need to be doing. What are you trying to accomplish? Jul 9, 2014 at 17:47
  • Why it is not good? Jul 9, 2014 at 17:53
  • 8
    @user3746280 why don't you explain the actual problem that you are trying to solve. You're probably falling into the XY Problem trap
    – MDMarra
    Jul 9, 2014 at 17:58
  • Publicly routable IPv4 addresses are a diminishing resource, make sure you are not frivolously using them up. Jul 9, 2014 at 17:59
  • Also, the guide you linked shows the old way of adding addresses, and it should not be used anymore. @andol's answer shows one current way to do it. And you still need to explain exactly what you are trying to do. Jul 9, 2014 at 17:59

2 Answers 2

7

than setting another VLAN and adding to it virtual interfaces

Sorry dude, this shows you have no idea what you're talking about. Why in the world do you want this anyways?

Are those networks routed to you? Or directly attached? It matters - you'll configure things differently.

Anyway assuming that the networks are routed to you, do something like this, not that eth0:0 nonsense.

auto dummy0
iface dummy0 inet static
    pre-up modprobe dummy
    address 150.50.50.0/32
iface dummy0 inet static
    address 150.50.50.1/32
…
iface dummy0 inet static
    address 150.50.50.255/32
4

Assigning 512 additional ip addresses to an interface shouldn't be any problem. Here is me adding 1000 additional addresses, ending up on a total of 1001.

root@tbox:~# for c in $(seq 1 4); do for d in $(seq 1 250); do ip addr add 10.0.$c.$d/32 dev eth0; done; done
root@tbox:~# ip addr show eth0 | grep -E "\binet\b" | wc -l
1001
root@tbox:~#
3
  • THanks for answer @andol. Is your way is better way (in mean of performance) than setting another VLAN and adding to it virtual interfaces? Jul 9, 2014 at 17:58
  • 3
    I have no idea what you are really trying to accomplish, and hence no idea what the best solution is. As people keep telling you, you really ought to add a bit more info to your original question.
    – andol
    Jul 9, 2014 at 18:00
  • I added comment to my question for what I will use ip's. Jul 9, 2014 at 18:09

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