1

is it possible to retrieve two or more IP's from different subnets over one network interface? Server has a default IP address of 192.168.178.50/24. Servers network interface eth0 is bridged on br0 together with some ve* interfaces from virtual machines. Now I will assign a static IP address for each of the VM's but not inside the 192.168.178.0/24 network.

Let's imagine I have several IP pools available (192.168.10.0/24 and 192.168.20.0/24).

The VM's /etc/network/interfaces will look almost like this (VM's interface is internally called eth0):

auto eth0
iface eth0 inet static
    address 192.168.10.10/24
    gateway 192.168.178.1
    dns-nameservers 8.8.8.8

My networks skills aren't that good that I can confirm myself that this could be working. Will the VM find the route through the standard gateway of the parent host that is also inside an "other" network range? Or is it required to edit hosts routing table? Furthermore packets should also be able to pass from the router to the VM.

Thanks for your help! (I'm using Ubuntu if this helps)

J. Pee
  • 42
  • 6

1 Answers1

4

No, your gateway needs to be in the same subnet as your host address, as that's the machine you contact to get out of your subnet (it's a router).

You can have multiple subnets on the same fabric and layer 2 broadcast domain, but you shouldn't do that in most cases, and should instead be separating subnets into individual VLANs and/or physical networks.

Also, this is serverfault. If this isn't an enterprise machine in a business facing environment (which the question does not appear to state), you should take questions of a limited scope or academic nature to superuser.

Spooler
  • 7,046
  • 18
  • 29
  • Ok. Any other suggestion to share IP pools between multiple servers on the same network? – J. Pee Sep 13 '16 at 14:50
  • You make a separate L2 broadcast domain for every separate IP subnet and route between them. That is how IP is designed to work and you cannot do otherwise. – Tero Kilkanen Sep 13 '16 at 15:28
  • So essentially what we mean by broadcast domain is a discrete physical network that only touches another though a router, or VLANs on the same physical network to accomplish the same. – Spooler Sep 13 '16 at 17:27
  • Keep in mind that when you have a host running one or more VMs, they're typically configured on a virtual IP network. This IP network can be completely different and they can use a bridged connection (the vm host acts as a bridge between LAN and the vm guests' virtual network) to access outside the virtual network. You're seeing bridging, and NAT routing. So the vm host acts as a router for the guests' virtual network. For each guest, the virtual network side of the bridge will be their gateway. – Jeter-work Sep 13 '16 at 17:32
  • I will look into this! Well explained @Xalorous. – J. Pee Sep 14 '16 at 12:54