Bridging two different subnets

This is for discussing general topics about how to use VirtualBox.
Post Reply
r0x0r
Posts: 4
Joined: 27. Apr 2011, 20:17
Primary OS: Fedora other
VBox Version: OSE other
Guest OSses: Windows 2008 R2

Bridging two different subnets

Post 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?
Last edited by r0x0r on 27. Apr 2011, 23:54, edited 1 time in total.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Bridging two different subnets

Post by Perryg »

Sure it's doable but you need to setup your router to do it for you the way you want.
r0x0r
Posts: 4
Joined: 27. Apr 2011, 20:17
Primary OS: Fedora other
VBox Version: OSE other
Guest OSses: Windows 2008 R2

Re: Bridging two different subnets

Post 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...
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Bridging two different subnets

Post by Perryg »

BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Bridging two different subnets

Post 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
Bill
r0x0r
Posts: 4
Joined: 27. Apr 2011, 20:17
Primary OS: Fedora other
VBox Version: OSE other
Guest OSses: Windows 2008 R2

Re: Bridging two different subnets

Post 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.
r0x0r
Posts: 4
Joined: 27. Apr 2011, 20:17
Primary OS: Fedora other
VBox Version: OSE other
Guest OSses: Windows 2008 R2

Re: Bridging two different subnets

Post by r0x0r »

ok i'm going to try the nictrace.
Post Reply