Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have Ubuntu 11.0.4 installed as a guest OS under VirtualBox on OS X Lion. I installed Apache and tested the server from Firefox on the guest. Now I'd like to connect from the host.

I followed instructions from two sources without success. From VirtualBox, add rule in the Terminal of the host:

VBoxManage modifyvm Ubuntu --natpf1 "apache,tcp,,8888,,80"

shut down Ubuntu

under Settings > Network Bridged Adaptor tried both en1: Wi-Fi and en0:ethernet

Restart VirtualBox

Restart Ubuntu

Remember to Allow from all in /etc/apache2/sites-available/default

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    # Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

Restart Apache

Safari: http://127.0.0.1 Safari: http://127.0.1.1 +/- :8888/

Doesn't say can't find server, but times out

The second approach from here:

Modify ~/Library/VirtualBox/VirtualBox.xml on the host added these to the top of the file under ExtraData

ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="2222" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" value="8888" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" value="80" ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" value="TCP"

No go. Any ideas what to try next? Thanks.

@Eric Fortis Tried going back to NAT. In the guest:

te@VB:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:88:33:a4  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe88:33a4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:69 errors:0 dropped:0 overruns:0 frame:0
          TX packets:91 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27935 (27.9 KB)  TX bytes:11313 (11.3 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

In the host, neither 127.0.0.1 nor 10.0.2.15 works.

Update: Trying bridged mode: Attached to: Bridged Adaptor Name: en1: Wi-Fi (Airport) Promiscuous mode: Allow all Cable connected: unchecked

In the guest:

te@VB:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:88:33:a4  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 

No ip address?

UPDATE 2:

Figured it out. I had Apache configured wrong for the new port. I used NAT with this from Terminal:

VBoxManage modifyvm Ubuntu --natpf1 "server,tcp,,8080,,8080"

I needed to modify ports.conf to add

> NameVirtualHost *.8080 
> Listen 8080

and sites-available/default to add

<VirtualHost *:8080>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

It comes from trying to learn too many new things at once. Thanks for your patience.

share|improve this question

migrated from stackoverflow.com Aug 13 '11 at 0:12

This question came from our site for professional and enthusiast programmers.

1  
is apache in your vhost configured to listen on the correct ports? this will work in bridged or nat mode, also check any firewall rules in the guest and that network access works out of the guest as well –  anthonysomerset Aug 13 '11 at 0:19
    
I forgot to listen on the new port (8888), but now that I added the Listen 8888, it still doesn't work. I'll have to work on the other stuff. Thanks. –  telliott99 Aug 13 '11 at 1:24

3 Answers 3

up vote 1 down vote accepted

The easy way to do this is to use the VirtualBox GUI under Settings, Network, Port Forwarding to create a port forwarding pair for each port that you need to have access to on the guest OS such as ssh, http, etc.

share|improve this answer
    
Didn't actually use the GUI, but this is basically what I did. I had Apache configured incorrectly. –  telliott99 Aug 14 '11 at 14:30

Set VirtualBox to NAT, instead of bridging, then from the host PC browser access the IP of the Ubuntu virtual machine, instead of 127.0.0.1. ifconfig will show you your IP.

share|improve this answer

It is easier if you have your guests network adapter configured for bridged mode. Ensure that your guest has an IP address in the same network as your host machine, you can use the ifconfig command to check, make a note of the IP address of your guest.

To access your guest from your host you can use http://ipaddress:8888 or you could edit the hosts file and add an entry for your guest so you can access it by name.

share|improve this answer
    
Trying bridged mode, I don't see an ipaddress when doing ifconfig in the guest. –  telliott99 Aug 13 '11 at 14:40
    
The DHCP server on your LAN has to be configured to give your guest an IP address, or you have to give your guest a static IP address. Here is a link to configuring a static IP address. liberiangeek.net/2011/03/… –  Iain Aug 13 '11 at 15:00
    
Thanks for the ideas. Lack of an IP address seems highly suggestive. However, I did follow the instructions in the link, and not only did it not work, now in the Control Center pressing the Network Connections button fails to bring up the next window, so there doesn't seem to be a way to reverse what I did using the GUI. I'll have to go to command line tools to fix that, I guess. –  telliott99 Aug 13 '11 at 20:15
    
Never mind, fixed by reboot. I'll try to figure it out. Thanks again. –  telliott99 Aug 13 '11 at 20:18
    
ifconfig eth0 down ifconfig eth0 192.168.99.14 netmask 255.255.255.0 up. Set the IP address and netmask to suit . –  Iain Aug 13 '11 at 20:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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