Friday, August 24, 2012

How can I access apache (on virtualbox guest) from host?

Article from -


Hi I installed Apache on Ubuntu in a Virtualbox. When I go into the guest and load up Firefox I can see that Apache is working fine when I browse to http://localhost.
I would like to access this same page through the host now. I've tried using the IP address of the guest but nothing comes up. Ideally I will set up my Win7(host) hosts file to send request to http://guestserver.comto the apache server on the guest. How can I do this? Thanks


If you need to allow other machines in your physical network reach your VM or if the VM needs Internet access, use bridged networking. Otherwise, stick to host-only networking.
  1. Stop your VM and open the settings for it in the VirtualBox (OSE) Manager
  2. Go to the Network tab
  3. Select the network mode at your choice (bridged networking or host-only) (in the below example, I'm using host-only)
    If you want to use bridged networking, you've to select the right network adapter at Name. For wired connections, you'd select something named like eth0. Wireless connections are usually namedwlan0 (the numbers may vary)
  4. Save the settings
  5. Start the Ubuntu VM
  6. When up, you can gather the IP address by running:
    ipconfig | config addr
    In the below output, is the IP address that can be used in your Win7 host system to access your VM:
    eth0  Link encap:Ethernet  HWaddr 08:00:27:70:27:fe  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::a00:27ff:fe7b:25fe/64 Scope:Link
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
  7. In your windows host system, edit C:\Windows\drivers\etc\hosts as administrator and add a line: If you've a Ubuntu host system, edit /etc/hosts using sudo nano /etc/hosts
  8. Profit!

No comments:

Post a Comment

I would be glad to know if this post helped you.