Accessing guest when host is on different network

Discussions related to using VirtualBox on Windows hosts.
Post Reply
ramiwi
Posts: 3
Joined: 25. Jan 2013, 19:35

Accessing guest when host is on different network

Post by ramiwi »

I`m running VirtualBox 4 on Windows 7 with a guest Ubuntu server 12 vm.
The host computer ip is 10.0.0.1 and the guest ubuntu is configured as 192.168.21.129 (i dont want to change these ip addresses).
How should i configure this setup so i can access the guest webserver from the host and from other computers on the lan?

Thanks
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Accessing guest when host is on different network

Post by Perryg »

Since the guest is not in the same subnet as the host you would need to have a router.
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Accessing guest when host is on different network

Post by noteirak »

Just to clarify on Perryg's thoughts, the router can be a VM, or the host, or a separate hardware - that is up to you.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
ramiwi
Posts: 3
Joined: 25. Jan 2013, 19:35

Re: Accessing guest when host is on different network

Post by ramiwi »

Thanks,
Which option is the easiest to configure? and how should i do it?
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: Accessing guest when host is on different network

Post by BillG »

Why do you not want to change the IP of the guest? It makes no sense for it to have a 192.168 address if all of the machines it needs to communicate with are in 10.0.0. Going to the trouble of installing a router and changing default gateways and/or installing static routes just to make this work for one machine would need a compelling reason (especially if you don't know how to do it).

If you do have some compelling reason, post a bit more information about how you network is configured.
Bill
ramiwi
Posts: 3
Joined: 25. Jan 2013, 19:35

Re: Accessing guest when host is on different network

Post by ramiwi »

I wanted this IP fixed because its used in several site configurations on this development server (the vm). The host pc is sometimes connecting to the internet through different router/modems so i thought it would be easier for me to this way, but its wont be the case if i will be adding special routes for other pcs, so eventually I just changed my current router subnet to match the vm`s ip.
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Accessing guest when host is on different network

Post by noteirak »

ramiwi wrote:Which option is the easiest to configure? and how should i do it?
Since you have a Windows host, I would go for a VM router - either pfSense or a minimum-install debian.

Virtualbox config will be as follow :
On your new router VM, 2 NICS :
1 bridged on your 10.0.0.x LAN, give it a static IP (let's say 10.0.0.253)
1 Internal under the name (purely arbitrary) "devLan"
Enable IP Routing in the VM (if not already)

On your Dev VM
1 Internal under the name "devLan" (the same as your router VM)

On your network (your actual hardware router) : route the 192.168.x.x network towards your router VM bridged IP (10.0.0.253 in this case)
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
jorgensen
Posts: 589
Joined: 20. Oct 2009, 01:22
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows

Re: Accessing guest when host is on different network

Post by jorgensen »

I can recommend reading a book about Ethernet networking and routing.
From your post, I am not sure if you are using NAT or Bridged Networking for the guest.
If using Bridget Networking, Virtualbox uses the standard rules for IP routing, where the setting of gateway is essential.
You can do a lot of routing in the Window 7 host - try the command 'route print' to get an idea.
Usually you can reach the host from guest by using the IP address.
Post Reply