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.com to the apache server on the guest. How can I do this? Thanks

link|improve this question

feedback

3 Answers

up vote 8 down vote accepted

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 named wlan0 (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, 192.168.56.101 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:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7b:25fe/64 Scope:Link
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
    
  7. In your windows host system, edit C:\Windows\drivers\etc\hosts as administrator and add a line:

    192.168.56.101 guestserver.com If you've a Ubuntu host system, edit /etc/hosts using sudo nano /etc/hosts

  8. Profit!
link|improve this answer
This worked perfectly for host-only networking and I can now access the guest from the host's browser. However with a bridged connection, which I would like, I don't have access to the internet from the guest. – drtanz Jul 7 '11 at 11:06
If anyone can help me out with the bridged connection that would be great, I don't know if I'm doing anything wrong, I just selected bridged and started up the guest, but didn't have any connection to the internet, neither from the host. – drtanz Jul 7 '11 at 12:11
That's weird, perhaps you need to reboot your physical machine? Please note that this Q&A site is for Ubuntu. If you've windows-related questions, visit superuser.com – Lekensteyn Jul 7 '11 at 13:26
Ok thanks, I switched to wireless connection and it works now, I'll restart later and if it doesn't work I'll ask on superuser.com, thanks for your help. – drtanz Jul 7 '11 at 20:53
@drtanz: I forgot about that, see the notes at step 3 – Lekensteyn Jul 7 '11 at 21:00
show 1 more comment
feedback

If you cant connect over ip you're not likely to have any success with dns names on a default apache install.

check the network settings of the virtual host, I always putt it to bridged to it can be accessed throughout the entire network.

link|improve this answer
I set it to bridged but now the guest doesn't connect to the internet. – drtanz Jul 7 '11 at 10:58
do you get an IP in the quest OS? I usually set up multiple NIC's to match all my physical NIC's. Can you perhaps dump your ifconfig from the quest and host – junke1990 Jul 7 '11 at 16:48
When I'm working with wireless it works but with cable no, here are some screenshots showing my config: imageshack.us/photo/my-images/832/guestr.png imageshack.us/photo/my-images/846/virtualbox.png imageshack.us/photo/my-images/9/hostwin7.png – drtanz Jul 8 '11 at 9:41
any help on this please? – drtanz Jul 10 '11 at 21:58
it looks like your computer is directly connected to the internet and that may be the reason why your client isn't getting a IP (v4) – junke1990 Jul 11 '11 at 8:36
show 5 more comments
feedback

In bridged mode, if your host uses a static IP address, you should manually config your guest IP in the same range with the host IP. Otherwise, the guest will not be automatically allocated with a valid IP address. HTH.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.