Page 1 of 1

Bridging two different subnets

Posted: 27. Apr 2011, 21:13
by r0x0r
Is there a way to make a bridge between two different subnets of host and guest os. I know this question may sound strange for the classic meaning of bridging. Network bridge works at the ethernet level and should not care about ip subnets. However something is wrong cause I can't get it working with VirtualBox.

I have a host os running on 192.168.1.10 (mask 255.255.255.255) with default gw 192.168.1.1. And I want to setup the bridge for my guest os to run on 192.168.2.10 (mask 255.255.255.0) with default gw 192.168.2.1. I have chosen Bridge mode in the VM settings and populated static IP info in the guest os. However, I can't ping 192.168.2.1 from guest os, it seems to be unreachable. It does reachable from the host os though. My host os is Centos 5.5, gues os is Win 2008 R2.

Are there any known bugs or limitations?

Re: Bridging two different subnets

Posted: 27. Apr 2011, 21:56
by Perryg
Sure it's doable but you need to setup your router to do it for you the way you want.

Re: Bridging two different subnets

Posted: 27. Apr 2011, 23:53
by r0x0r
Please explain what you mean. I have the routers at 192.160.1.1 and 192.168.2.1, both can route to other subnets. For example, I can bring up the second interface on the host with 192.168.2.10 and have 192.160.1.1 as main gw for both and everything will work fine. But when I do it in the guest os using bridged NIC it becomes unreachable. Can't find what I am doing wrong...

Re: Bridging two different subnets

Posted: 28. Apr 2011, 00:02
by Perryg

Re: Bridging two different subnets

Posted: 28. Apr 2011, 01:59
by BillG
Your problem has nothing to do with VirtualBox really. That won't work with physical hardware and networks either (unless you use NAT). It won't work without NAT because the gateway router (which is the dg for the 192.168.1 subnet) has no idea where the 192.168.2 subnet is.
See this example I posted in a networking forum sometime.

If one subnet is using another router as its gateway, you need to use NAT, or add extra routing to the existing gateway router to get traffic
to the internal router.

Internet
192.168.1.1
|
192.168.1.x dg 192.168.1.1
|
192.168.1.254 dg 192.168.1.1
router
192.168.2.1 dg blank
|
192.168.2.x dg 192.168.2.1

Without NAT you need a static route on the gateway router to get traffic for 192.168.2.0 to the internal router.

192.168.2.0 255.255.255.0 192.168.1.254

Re: Bridging two different subnets

Posted: 28. Apr 2011, 11:20
by r0x0r
The thing is it's all have been done already. I can ping 192.168.2.1 from my host os with default gw 192.168.1.1. It's only unreachable from VirtualBox guest os.

Re: Bridging two different subnets

Posted: 28. Apr 2011, 20:10
by r0x0r
ok i'm going to try the nictrace.