2

I am thinking if it's possible to create a bridge while allowing each bridged network to exist in it's own subnet.
Network 1 - Say, I have a physical ethernet based network eth01 - with subnet 192.168.x.x/16.
Network 2 - I want to create another virtual network veth01(based on virtual interface) with subnet 172.16.x.x/12.

Now is it possible to create a linux bridge (virtual not physical) between Network1 and Network2, such that even after bridging the above two networks have there on subnets and there own DHCP.

Any reference or steps/commands on how to create this setup (if possible) are highly welcomed.

samshers
  • 238

1 Answers1

4

You are thinking wrong on several levels.

  1. A bridge is a layer 2 device. If you connect two networks by a bridge, you are creating a single layer 2 network comprising both of the connected networks - in your case, the physical Ethernet based network connected to interface eth01 and the virtual network connected to interface veth01. Any layer 3 network carried on one of these network will then also be carried on the other one.
  2. There is no one-to-one relation between layer 2 and layer 3 networks. So in your scenario, the bridged network comprising the physical Ethernet and the virtual network can carry both the subnet 192.168.x.x/16 originally carried by the physical Ethernet on eth01 and the subnet 172.16.x.x/12 originally carried by the virtual network on veth01, without the two interacting in any way. (Except possibly competing for bandwidth.)
  3. DHCP is not "owned" by a network. You can run several DHCP servers on one layer 2 network if you do it carefully, and you can also run a single DHCP server serving several layer 2 network.

From your question, it seems what you want to do is configure two DHCP servers so that one of them serves only clients on the physical network and the other one only clients on the virtual network. This is something that cannot be easily done if you install a bridge between the two, as the bridge effectively removes the distinction between the two. If you need that, you should either reconsider your decision to use a bridge, and go for routing instead, or you need to find a distinguishing attribute for your DHCP server to decide from which layer 3 network it should take the IP address to assign to a given client.

Tilman Schmidt
  • 4,335
  • 15
  • 29