Setup a Test Lab With VirtualBox, depreciated

I found a much simper way to do this! See my updated blog post Setup a Test Networking Lab With VirtualBox

I’m always playing around with new IT technology. Up until recently I just did it with VirtualBox on my PC’s and messed with the network and then cleared up the mess afterwards. This was not good, not to mention a waste of time when I could be playing around with the next new shiny bit of tech or software.

So I decided to look into setting up a PC that could host many virtual machines and have those connected to their own test network without destroying the network for the real machines. Yes, I know should have do it years ago! The key parts were finding pfSense and the VirtualBox Host-only network settings.

My host machine is an 8 core AMD running at 3.8GHz, 32GB RAM, 2TB free disk space, and a wall of monitors. This is all running on Ubuntu 12.04 LTS. I only use the LTS versions I like the stability. I also set cup-frequency-set to performance.

This HOWTO, assumes you can download software, create and install VM’s. Use Linux to edit conf files and install software.

Install VirtualBox, either from the Ubuntu repos or download it from Oracle. Once installed add the extension package, which is a seperate download. If you cannot manage that by yourself then this how to is beyond your capabilities and you should go find a hobby outside the computing industry. Wow, still with me so lets get on!

We will be setting up a virtual network for our test lab, that means the NICs on the lab machine will not be able to see our real PC’s and visa versa. So we need to configure the VirtualBox Host-only networking and get a router so the lab machines can talk to the internet to down load software.

Setup VirtualBox Host-only Networking

Fire up the GUI for VirtualBox, from the command line use:

virtualbox

once it is open go to File -> Preferences -> Network. On the right hand side there are some tabs we want the Host-only tab. For this HOWTO we only want one Host only network so edit one or create a new one by using the little icons on the right hand edge.

VirtualBox-Settings-disable_DHCP

We want to disable the DHCP as that is one of the things we will be running in our test lab.

VirtualBox-Settings-Network

Setup Virtual Router, pfSense

pfSense acts among other things as a virtual router. This will be the gateway out tot the real world for our test lab. If you are at home you probably have an ADSL modem/router. This may even have some extra ports and double up as a switch too! pfSense take the place of that without the switch part.

Download it from pfSense downloads. Once you have downloaded the ISO take a look at the Getting started page, it’s all pretty standard stuff for installing a VM. You only need a little VM as shown briefly below:

  • Name: lab-router
  • Type: BSD
  • Version: Free BSD(64bit)
  • RAM: 512MB
  • CPU: 1
  • Storage, HD 8Gb
  • Storage, CD point at pfSense Live ISO
  • Network
    • 1. eth0 Bridge
    • 2. eth1 Host-only

When booting pfSense accept the default at the first prompt, the one with the countdown. The press I to install at the second. I then went for the Quick install.

After the first boot there are some prompts to setup interfaces

  • Do you want to setup VLANs now? : N
  • Enter the WAN interface name or ‘a’ for auto-detection: em0
  • Enter the LAN interface name or ‘a’ for auto-detection: em1
  • Enter the optional 1 interface name or ‘a’ for auto-detection: Press Enter
  • Do you want to proceed? : Y

There will be lots of output to the screen and then a menu. Above the menu you will seethe configuration for the two NIC is. Mine looked like this:

WAN (wan)  -> em0      -> v4/DHCP4: 192.168.0.124/24
LAN (lan)  -> em1      -> v4: 192.168.1.1/24

Setup the router connection, from our test lab’s point of view it goes to the internet. In reality it goes to our real LAN. To set up the WAN.

  • Select 2) Set Interfaces
  • Enter the number of the interface you wish to configure: 1
  • Configure IPv4 address WAN interface via DHCP? N
  • Enter the new WAN IPv4 address.: 192.168.0.20
    • The address you enter here is the outside address for your test lab.
    • It needs to be an unused address on your real LAN.
  • Subnet masks are entered as bit counts: 24
  • Enter the new WAN gateway? 192.168.0.1
    • This is the gateway you use on your real LAN, probably your own real router.
  • No need for any IPv6 setups, YET!
  • Do you want to revert to HTTP as the webConfigurator protocol? N

The config on mine now looks like this:

WAN (wan)  -> em0      -> v4: 192.168.0.20/24
LAN (lan)  -> em1      -> v4: 192.168.1.1/24

That is pfSense almost setup. We will come back to it later.

Install Some Virtual Machines

Now we need some machines so we can start to play around with things in our lab. I started with a minimal install of Ubuntu 12.04 LTS Desktop. It’s quick and easy. Although you may find it simpler to create this VM outside of the test lab, using a Bridged NIC and then change the NIC back to Host-only once it is installed. I set this first one up with a static IP address

auto eth0
  iface eth0 inet static
  address 192.168.1.2
  netmask 255.255.255.0
  gateway 192.168.1.1
  dns-nameservers 8.8.8.8
  • Name: lab-desktop
  • Type: Linux
  • Version: Ubuntu (64bit)
  • RAM: 2048MB
  • CPU: 2
  • Storage, HD 25Gb
  • 1. eth0 Host-only

Remember you can over provision, RAM and CPUs with VirtualBox.

Finish Configuring pfSense

Once you have a working VM with a GUI, install the VirtualBox Tools and then fire up you favourite browser and point it to the psSense router. Mine is https://192.168.1.1

The default user name and password are: (you will want to change these)

Username: admin
Password: pfsense

Once you are logged in start the setup setup wizard from System -> Setup Wizard

Take note of the WAN Gateway: Set this to your home’s router IP address. This will ensure that pfSense knows where to send all of the VM’s internet traffic out to the internet.

hostname: lab-router
domain: whatever.lab
Primary DNS 192.168.0.4
Secondary DNS: 8.8.8.8
Tick Allow DNS to be overridden…
Next …

Set the Time server host to something close to where you are, I use
0.uk.pool.ntp.org
Europe/London
Next …

Static IP Configuration
IP Address: 192.168.0.20 ( this is the address you already set above. It is the address the other side of the router)
Gateway: 192.168.0.1 (point this at your router on your real LAN.)

That was it for that page,
Next …

Configure LAN interface
LAN IP Address: 192.168.1.1 (you have already set this up, you are using it for the HTTP connection :-))
Sub Mask : 24
Next …

Set Admin WebGUI Password

Admin password: notsosecret
Admin password AGAIN: notsosecret
Next …

Reload …

Allow a short wait… wait a little longer… and possibly a little bit more.

Congratulations! pfSense is now configured.

Now you should be able to reach the internet from lab-desktop. That is you can browse the web, and ping bbc.co.uk or cnn.com.
You will not be able to see or interact with your real LAN.

That’s pretty much all there is to it. If you want to use the test lab just set the NICs on the VM’s to Host-only and you are sorted.

Leave a Reply

Your email address will not be published. Required fields are marked *