How to setup an Active Directory domain controller in VirtualBox

Over the next three days I’m going to show you how to setup Active Directory and join a PC to your new domain but I want you to know this isn’t something you can learn by reading.  You need to do it.

You need to sit in front of a real Windows Server 2012 machine.  You need to join a real Windows workstation to the domain.  You need to interact with the software.

But how can you realistically do this?  Well there are two options; no wait – three options:

  1. You could completely abase yourself by buying your boss’s children Christmas presents so he would be more amenable to letting you setup a lab in the office.
  2. You could cough up a butt load of money to buy real equipment
  3. You could setup a free virtual environment on your computer in a completely isolated network.  Then you could install Windows 8.1 and Windows Server 2012 virtual machines and configure a virtual switch to connect both computers.

Are you with me on option 3? I hope so!  Let me show you how simple it is to pull this off.

“Simple” and “quick” aren’t synonyms.  So although it’s easy to get going it will take a few hours to download all the files and configure your virtual environment.

Let’s get started.

If our virtual Active Directory Domain controller were a big juicy burger we would need a few ingredients to make it:

  • VirtualBox
  • Windows 8.1 Pro
  • Windows Server 2012 R2
  • pFSense

Snag VirtualBox

First, download and install Virtualbox on your host machine.  Keep all the defaults.  The install should zip by in seconds.  This is the bun for our proverbial burger.

Filch Windows 8.1 Pro

Next, we need to obtain a real Windows 8.1 Pro ISO image.   You can download the Windows 8.1 Pro media directly from Microsoft.  In fact, if you can actually legally download every version of Windows for free.  Consider this the lettuce and tomatoes.

Grab Windows Server 2012 R2

You can get the Windows Server 2012 R2 iso directly from the Microsoft Evaluation Center.  Just signup and download.  This is the 1/4 pound of grass fed organic beef.  Without this our Active Directory burger is nothing.

Pilfer pFSense

pFSense will be the virtual router that gives us the liberty to connect our internal VirtualBox guest machines to the internet. pFsense is our special sauce.

Completing the above four steps could take several hours because of the sheer size of the Windows ISO files.  These files are gargantuan (4GBs per file) so make sure you have ample space on your hard drive before you start the download frenzy.

Once you have all the ISOs on your computer we can setup the virtual machines.

Configuring the Virtual Machines

Setting up Windows 8.1 Pro in VirtualBox is almost identical to setting up Windows 10 in VirtualBox.  The only difference is that under the Network tab in your VirtualBox Settings, Adapter 1 must be set to Internal Network.  The name should also match for all hosts participating in the same internal network.  I recommend the default intnet.

The internal network adapter names must match on your VirtualBox hosts

To setup your virtual machines, click the prickly blueNew button in the Oracle VM VirtualBox Manager and pick your OS version and memory size.  Leave the Hard drive defaults alone and click Create.

Windows Server 2012 Virtual Machine

Click Create again on the next screen to keep all the defaults for the file size and physical hard drive type.

VirtualBox setting defaults

After creating the image, select it and choose Settings from the Oracle VM Virtualbox Manager screen.

Pick the Storage tab, and under the Storage Tree you should see a CD icon.  We need to browse to the ISO we downloaded earlier so that the Virtual Machine will boot to it just like a real machine would boot to a physical CD.

Adding the ISO to VirtualBox

Now you can go through the installation just like a normal install.  Install Windows 8.1 Pro in the same fashion.

After you have both operating systems installed you’re ready to setup pFSense.

Making sense of pFSense in VirtualBox

Getting pfSense to work in VirtualBox is basically the same except for a few differences:

Under Settings > System > Motherboard the Base Memory should be set to 256 MB.  As you can see pFsense doesn’t need a lot of memory: 256 MB is sufficient.

pFSense in VirtualBox

Next, under the Network tab under Adapter 1, make sure it’s enabled and attached to your Bridged Adapter.  This will be come your WAN (internet facing) interface in pfSense.

Setting the network settings for pFsense in VirtualBox

Then boot up the virtual machine and press Enter on the boot screen

boot up pfSense

Quickly press “i” to dive into the Installer setup.

Enter the pFsense Installer

In the blue Configure Console screen, choose < Accept these Settings >.

fixedbyvonnie-pfsense-setup

Go with the < Quick and Easy Install >

Quick and easy pfSense

Go ahead and erase the Virtual Disk.  There’s obviously nothing on it.

Erase the virtual disk

Choose the Standard Kernel

Use the Standard Kernel

Then once the installation finishes, eject the virtual CD and reboot.

Eject the pFsense ISO

Boot to the main screen and skip the question about setting up VLANs.

Right now, we need to assign our interfaces so press 1.

pFsense mainscreen

You’ll be asked to enter the WAN and LAN interface names.  Use em0 and em1 respectively.  em0 should correspond to your bridged virtualbox interface.

em0 and em1 for pfSense

Great, when this finishes press the number 2 to configure the IP subnet for the LAN.

I used 10.0.0.254 with mask 255.255.255.0 (24 bit mask).

Configuring the adapters in pFsense

There’s no need to enable DHCP or revert to HTTP so just press enter to skip passed those options.

pFsense Configured

 

We’re done with our pFSense setup!  Leave it running and minimize the virtual machine window.

Setting IP addresses on the Windows guests

Now we’re ready to configure the static IP addresses on our Windows guest machines.

Open up the Network Connection settings in your Windows Server 2012 machine and configure the following settings for your Internet Protocol Version 4 (TCP/IPv4) item:

10.0.0.11
255.255.255.0
10.0.0.1

Windows Server 2012 settings for VirtualBox

The DNS should be 127.0.0.1 since we’re going to use the server itself as the DNS server.

On the Windows 8.1 Pro host, set the network settings as follows:

10.0.0.12
255.255.255.0
10.0.0.254

Windows 8.1 IP Settings

Also notice the DNS server is set to the IP of our Windows 2012 Server: 10.0.0.11.

Now as long as both machines have network adapters set to Internal Network with the same name, you’ll be able to communicate.

Let’s just kick off a ping to verify…

Pinging the domain controller

W00t!

Tomorrow starts your adventure setting up a Windows Server 2012 Active Directory environment.

You now have everything you need to follow along.  You can do this.  You will do this.  I believe in you.

About

Connect with Vonnie on Twitter

Posted in Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Vista, Windows XP Tagged with: , , ,
  • NewbieGeek

    followed your instructions to download windows 8.1, but it won’t install without first entering a product key. Also tried to download and install windows 7. the link you provided goes to a site “that has been moved”. MS site it redirects to requires product key before it will even download.

  • nicechap

    I have followed the steps to the letter and my two virtual machines can communicate with each other but none of them can access the internet. Please how do I configure them to access the internet? Thank you.

  • Tuppence Farthing

    This project is super great and just what I was looking for to setup a test AD environment. Thank you for doing it! I think I’ve found a few missing pieces in the instructions when setting up PFSense. Also as nicechap has indicated – access to the internet seems to be broken – but I assume this is due to DNS not being setup or setup correctly.

  • jeffrey

    pfsense 2.2.6 rejects lan name em1 as invalid…