0

I've got VirtualBox set up so that I can access a web server on the guest from the host, using Bridged Networking. as I understand it, with Bridged Networking the guest machine gets internet access in the same way the host machine does - by getting an IP from your router, for example...

my problem is that I find myself wanting to work while traveling (ex: on a train), where I may not have internet access. without internet access, Bridged Networking falls apart.

it seems like there ought to be a way to set up Virtual Box so that there's some entirely made-up network that I can use, without a real one. I've tried "Internal Network" and "Host-only Adapter", which seem like they should do the job, but either they don't do what I want, or I'm misunderstanding how to use them.

tl;dr: is there a way I can access my guest machine's web server (and/or other network services) even when the host is without internet access?

1
  • 2
    Why not use the internal network as a second network adapter? That's how I mostly work. You can still access your virtual machine through the local address (if you use internal network, it is an address in the range 192.168.51.xxx).
    – Styxxy
    Dec 4, 2012 at 19:37

3 Answers 3

1

Funnily enough I have been doing this exact same thing today on my Dell Mini 9. Host OS is Windows 7, guest is Ubuntu Lucid (10.04) - everything working fine with bridged networking connecting from host to an R-server on the guest. But away from my network on the train I couldn't connect.

Eventually got it to work by using host-only networking, static IP on guest and setting a static IP on the virtualbox host adapter, and now works fine either connected to network or not. Only issue is that I can't connect to the guest from the rest of my network. I don't need to. (I didn't really want to use NAT because my home network uses the 192.168.. IP range)

Update by also bridging the virtualbox host adapter and the real network interface and again setting a fixed IP address on the bridge I can connect from my network to the guest.

1
  • this worked perfectly! thanks! (I also did not want to use NAT for similar reasons: depending on the network I end up at on the other end of my travels, the network settings might not be compatible. for that reason, something entirely-internal seemed preferable, and I also have no need for the rest of my network to see the virtual, guest machine.) thanks again!
    – Ben
    Dec 5, 2012 at 18:50
1

Definitely, NAT is the way to go (Lord Peter's recommendation above). The beauty of that solution is that you can access the internet from your VM when you have external connection. While off-line you could access VM Webserver with-in VM. The downside is that external machines won't be able to access your VM since it will be NAT'ed with your laptop; you can rectify that by either using a reverse proxy on you laptop or switch back to bridged configuration on the net.

If you are doing web development using LAMP, have you looked at LAMP web-dev stacks that can be installed either on USB Stick or your laptop directly. More on that below

http://www.apachefriends.org/en/xampp.html

1
  • I did used to run LAMP on the host/real machine - my laptop - however I prefer to develop on Windows, and the web app we're developing runs best on Linux. (the web app has become increasingly complex and I'm the only one on the dev team that cared about whether it also ran on Windows :P keeping it cross-platform became too much work, so I came to this solution: host it on a virtual machine.)
    – Ben
    Dec 5, 2012 at 18:38
0

NAT is the way to go. the NAT network uses the 10.0.0.0/8 range and assigns the guest an IP address automatically. the only trick to it is that you need to forward the port (80?) through your virtual NAT. once everything is set up all you have to do is plug the 10.0.0.x/8 address into your browser to access the site.

See Here (under "Configuring port forwarding with NAT") for instructions on how to set up a forwarded port, as well as a formal definition of the VBox network modes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .