Community Documentation

3a) Remote Access Quickstart: Bridged Networking

Last updated February 8, 2012. Created by MichaelCole on May 3, 2010.
Edited by marcel66, Danny_Joris, rootwork, zanix. Log in to edit this page.

Out of the box, Virtualbox has the host computer (Windows/Mac) to act as a NAT for the guest (Quickstart). This means Quickstart can see the rest of the network, but the network can't see Quickstart. If you want to access the sites on Quickstart from the host computer (or any other computer on the network) in a web browser or to edit the files, you'll need to use one of the options below to make Quickstart visible.

Four options have been developed. Please note:

  • These options are user-suggested. Use at your own risk.
  • Different network configurations and computer setups greatly affect the success of these networks. You might have to fiddle with these.
  • Consequently, please don't file support requests for this setup.
  • There may be security issues for some of these options on shared networks -- proceed with caution!

Options for accessing Quickstart files remotely:

Bridged networking option

Quickstart can become visible to the rest of the network through "Bridged Networking".
Virtualbox adds a MAC address to the host NIC, which Quickstart uses to get it's own IP address.

WARNING! This is a security risk!

Quickstart was designed to work protected by a NAT Firewall. It has known passwords for both the Quickstart and root user. If you follow this, please change the passwords for these two users. See http://drupal.org/node/1080160

If you enable bridged networking, anyone who sees your Quickstart on a network (wifi), THEY WILL BE ABLE TO LOGIN TO YOUR DEV ENV AS ROOT. Please perform your own security assessment, and report any opportunities for improvement in the project issue queue.

This is a bit advanced, so it doesn't have to make sense, but know it may not work on all computers. Please don't file support requests on bridged networking.

Configure bridged networking

1) Shut down Quickstart
2) Start Virtualbox

  • right-click the Quickstart entry (don't start it) -> settings
  • Choose "Network" from the left list
  • Change the "Attached to" field from "NAT" to "Bridged adapter". If you have more than one network adapter, choose an appropriate one in the "Name" field.
  • Ok

3) Start Quickstart

If necessary, tell Ubuntu to restart the network to get a new IP:

  • In the top left, click the radar with red ! and select Auto eth0.
  • The radar will turn to an up/down arrow icon.

4) Find the new IP address:

  • Right-click over that "up/down" arrow icon and select "Connection information".
  • Or alternatively, use this command: (run in the terminal, which can be started using the icon: black box with a > in it):
  • $ ifconfig eth0
  • ifconfig will output something like this:
  •         eth0      Link encap:Ethernet  HWaddr 08:00:27:16:f6:02 
                      inet addr:192.168.1.8  Bcast:192.168.1.255  Mask:255.255.255.0
                      inet6 addr: fe80::a00:27ff:fe16:f602/64 Scope:Link
                      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                      RX packets:115 errors:0 dropped:0 overruns:0 frame:0
                      TX packets:114 errors:0 dropped:0 overruns:0 carrier:0
                      collisions:0 txqueuelen:1000
                      RX bytes:29606 (29.6 KB)  TX bytes:76916 (76.9 KB)
                      Interrupt:10 Base address:0xd020
  • the "inet addr" field shows that Quickstart's new IP address is 192.168.1.8

5) If you type "http://192.168.1.8" into another computer on the network, you would get the "Quickstart" page from the computer.

Quickstart gives each website it's own "domain" by editing the /etc/hosts file. Run "drush quickstart" in the terminal for more information.

Quickstart uses Apache's "Virtual Hosting" to run more than one website on the same IP.

For this to work, Apache uses the URL address to figure out which "virtual host" website to use when it gets a request.
When Apache gets requests with only an IP, it doesn't know how to respond, and shows the default site.

To get to the website from another "web browser computer", that computer must make the request with the same URL used in Quickstart.
This "web browser computer" can be Quickstart's host computer, or another computer on the network.
To accomplish this, the "web browser computer" must translate the URL to Quickstarts new IP. This is usually done through a "hosts" file.

6) In Quickstart:

  • go to the desktop
  • open the websites folder -> config folder -> open the hosts file
  • copy all the lines with #quickstart at the end. E.g.
  • 127.0.0.1  mysite #quickstart
    127.0.0.1  othersite #quickstart

7) On the "web browser computer", paste these lines into the bottom of it's "hosts" file:

192.168.1.8  mysite #quickstart
192.168.1.8  othersite #quickstart

This file can be found:
  • unix: /etc/hosts
  • windows: C:\WINDOWS\system32\drivers\etc\hosts
  • mac: /etc/hosts
  • For detailed instructions, Google "edit hosts ".

8) Once this is complete (the computer may need to be restarted), you can access the website on the "web browser computer" using the url: http://mysite

By default, Quickstart will use DHCP. You can change this to a static IP if you like. DHCP servers give a "IP lease" for a certain amount of time (this is configurable on the router/server). How the DHCP server gives out leases may vary, but generally if you keep using the IP, when the lease needs to be renewed, you'll get the same IP and won't need to re-edit the /etc/hosts file.

Notes on this method

  • Yes, it's complicated and depends on your network config.
  • Yes, your mileage may vary.
  • You will get better results with bridged networking if you use Quickstart on the same network, every day. Switching wifi networks or from Ethernet to wifi might require changes to the host files each time.
  • The bridged network setting in Virtualbox has been known to cause kernel panics in some Macs.

OpenSSH server option

From user Danny_Joris:
You can create an (s)FTP and SSH (using putty on winOS) connection by installing OpenSSH on the Guest OS (quickstart). Instructions are here: https://help.ubuntu.com/10.04/serverguide/C/openssh-server.html . Only need to install openssh-server on the Guest OS if you're using Putty (as far as I know).

This can be useful if you want to use a code editor that is located on the Host OS. I still have to test this more in depth, but I assume it takes off some CPU load off the VM.

Note: Bridged networking may need to be set up anyway in order to use this option. Bridged networking does not need to be set up. It works perfectly with NAT and Host-Only combined. This way you can enable quickstart and have it run in the background without actually needing to go in the GUI of Ubuntu. (This is a performance saver.)

New listening port on Apache option

From user pau1_m:

This solution is not dependent on fixed IPs or making changes to the host OS.

First, add a new listening port to Apache. In this example I'm going to use port 55555.
In ports.conf located at /home/quickstart/websites/config/ports.conf

Add this line to the end of the file:

NameVirtualHost *:55555
Listen 55555

Now we tell apache to point this port to example.dev. Edit the file at /home/quickstart/websites/config/apache-sites-enabled/example.dev and change the first line <VirtualHost *:80> to <VirtualHost *:55555>

In the terminal, restart Apache:

sudo apache2ctl restart

Ensure that networking mode is Bridged rather than NAT.

You should now be able to access example.dev from a browser on the host (or any other machine on the network) by entering the guest's IP and site's port number. In my case this is:

http://192.168.0.8:55555

If you use NAT verify your IP - usually something like 10.0.2.2. In this case the address should be:

http://10.0.2.2:55555

Or on the guest at:

http://localhost:55555

This procedure can be followed for any number of sites -- just use different port numbers for each.

Two network adapters option

From user derhasi:
This approach works with using two network adapters, one via NAT for the connection to the internet, and one via Host-Only to provide a static IP connection from Host to guest. This is advanced -- see the Virtualbox networking documentation)

What's important is with this additional IP address, other computers on the network can access Quickstart as if it was a separate computer. This allows Quickstart to act as a web server to other OSes.

Comments

shouldn't we change the IP address?

At step 7), shouldn't we change (in "/etc/hosts" on the "web browser computer") the IP address from the localhost IP Address (127.0.0.1) to the actual Quickstart IP Address?

Exactly what i thought!

In the example it would be 192.168.1.8

Good catch! (late to the party)

I'll update the page. Feel free to edit if you find other errors in the documentation.

Thanks,

Mike

Won't Quickstart's IP change

Won't Quickstart's IP change sometimes after restarting, due to DHCP, and require updating the "web browser computer's" host file?

Yes it will, especially when

Yes it will, especially when you change the network that your Host connects to.

There is another approach, that seems to work for me. It works with using two network adapters, one via NAT for the connection to the internet, and one via Host-Only to provide a static IP connection from Host to guest.

This sounds like a REALLY good idea

I generally preferred bridged networking, as it seemed to make host to guest communications relatively painless.

However if running the VM on a laptop, that means changing the VMs bridged interface when e.g. moving to/from ethernet & Wifi, which can be a pain, and also might require updates on the host machine's /etc/hosts file.

Your suggestion for two guest interfaces, one Host Only and one NAT, solves these issues quite neatly.

The hidden bonus of this 2 VM interface method is that other hosts don't by default have a route to your VM's interface, so your VM defaults to being more private.

Trying it out and it seems to work just great! Ace tip.

Nice!

Brilliant! Love it.

Care to write this up as a new page?

Different solution to the same problem

I came up with a different solution to the same problem.

It doesn't require changes to the host OS and makes a Quickstart site available to any machine on the same network.

Awesome

Awesome

Freelance Web Design and Development
---
http://www.danlobo.co.uk

NAT vs Bridged

I'm confused if this is a required tutorial for getting quickstart configured or a tutorial moreso for remote access. I'm using this for localhost development. So, I would guess not mess with it if it is running smooth and simply change the passwords for security reasons. Yes?

"I can't be fooled by your hollywood trickery!!!" - Peter Sellers -The fiendish plot of Dr. Fu Man Chu

_

You can create an (s)FTP and SSH (using putty on winOS) connection by installing OpenSSH on the Guest OS (quickstart). Instructions are here: https://help.ubuntu.com/10.04/serverguide/C/openssh-server.html . Only need to install openssh-server on the Guest OS if you're using Putty (as far as I know).

This can be useful if you want to use a code editor that is located on the Host OS. I still have to test this more in depth, but I assume it takes off some CPU load off the VM.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x, Drupal 7.x
Audience
Developers and coders, Site administrators

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here