Print-ready version Back to the article
HMMNM Security
hmmnm.com

Security

Build a Two-VM Active Directory Lab: Domain Controller and Workstation with VirtualBox, Step-by-Step

By Prabhu Kalyan Samal | Published 22 November 2026 | 8 min read

https://hmmnm.com/build-a-two-vm-active-directory-lab-domain-controller/

9 min read · 1,672 words

TL;DR: You can build a fully functional two-VM Active Directory lab in about an hour: one Windows Server 2019/2022 VM promoted to a Domain Controller, and one Windows 10 VM joined to the domain over a VirtualBox internal network (10.10.10.0/24). This article walks through VM sizing, DC promotion, domain join, AD object creation, verification, and three hardening habits you should practice from day one.

Authorization note: everything in this tutorial is meant for machines you own, on isolated lab networks you create yourself. Active Directory攻击 tools and techniques should only ever be exercised against your own lab — never against systems you don’t have explicit written permission to test.

Why build an AD lab?

Active Directory is the backbone of nearly every enterprise network, and it’s the number one target in real-world intrusions. If you want to learn attack paths (Kerberoasting, ACL abuse, lateral movement) or defensive detection engineering, you need a domain to experiment in. A two-VM lab — one Domain Controller and one domain-joined workstation — is the minimum viable environment for almost all of it.

Lab topology and VM specifications

We’ll use VirtualBox’s Internal Network mode so both VMs talk only to each other, with no internet exposure unless you explicitly add a second NAT adapter for updates.

VM OS vCPU RAM Disk Network
DC01 Windows Server 2019/2022 Standard (Desktop Experience) 2 4 GB 60 GB Internal Network: ADLab
WS01 Windows 10/11 Pro 2 4 GB 60 GB Internal Network: ADLab

Network addressing for the lab:

Host IP Address Role
DC01 10.10.10.10/24 Domain Controller, DNS Server, (optionally DHCP)
WS01 10.10.10.50/24 (static, or via DHCP later) Domain-joined workstation

Configuring the internal network in VirtualBox

For each VM, open Settings → Network → Adapter 1, check Enable Network Adapter, set Attached to: Internal Network, and name it ADLab. Do this for both VMs before first boot so Windows detects a single clean adapter.

Tip: give DC01 a second adapter attached to NAT if you want Windows Update access during setup. Disable it after patching to keep the lab isolated.

Step 1 — Configure DC01 networking

Boot DC01, complete out-of-box setup with a strong local Administrator password, then set a static IP. Open PowerShell as Administrator:

Get-NetAdapter

Name      InterfaceDescription       Status
----      --------------------       ------
Ethernet  Intel PRO/1000 MT Desktop  Up
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 10.10.10.10 -PrefixLength 24 -DefaultGateway 10.10.10.1
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 10.10.10.10
Set-DnsClient -InterfaceAlias "Ethernet" -RegisterThisConnectionsAddress $true

The default gateway doesn’t exist on the internal network — that’s fine. Setting one keeps the “no default gateway” nag silent and helps if you add a router VM later. Pointing DNS at itself is required, because the DC must resolve its own domain records.

Step 2 — Promote DC01 to a Domain Controller

The legacy dcpromo GUI tool is deprecated since Server 2012. Modern promotion is done with the Install-ADDSForest PowerShell cmdlet, after installing the AD DS role:

Install-WindowsFeature AD-Domain-Services -IncludeManagementTools

Success  Restart Needed  Exit Code  Feature Result
-------  --------------  ---------  --------------
True     No              Success    {Active Directory Domain Services, ...}

Now promote the server and create a new forest:

Install-ADDSForest `
  -DomainName "lab.local" `
  -DomainNetbiosName "LAB" `
  -ForestMode "WinThreshold" `
  -DomainMode "WinThreshold" `
  -InstallDns:$true `
  -NoRebootOnCompletion:$false

WARNING: Windows Server 2022 domain controllers have a default for the
security setting "Allow encryption oracle connections"...
Password: ********
Confirm password: ********

Success  Restart Needed  Exit Code
-------  --------------  ---------
True     Yes             Success

You’ll be prompted for a Directory Services Restore Mode (DSRM) password — record it somewhere safe; it’s your break-glass credential. The server reboots automatically. After reboot, log in as LABAdministrator.

Verify the DC is healthy:

Get-ADDomain

Forest                  : lab.local
NetbiosName             : LAB
DomainModes             : Windows2016Domain
DnsRoot                 : lab.local
DomainController        : DC01.lab.local
...
dcdiag /v | Select-String "passed|failed"

e18f2e04-dallas... passed test Connectivity
... passed test NetLogons
... passed test SysVolCheck

DNS and DHCP notes

DNS: AD is inseparable from DNS. The promotion created a DNS server on DC01 with the lab.local zone and the essential SRV records (_ldap._tcp.dc._msdcs.lab.local, etc.). Workstations must point their DNS at the DC or domain join will fail. Verify with:

nslookup -type=SRV _ldap._tcp.dc._msdcs.lab.local

_ldap._tcp.dc._msdcs.lab.local  SRV service location:
    priority       = 0
    weight         = 100
    port           = 389
    svr hostname   = dc01.lab.local

DHCP: For a two-VM lab, static IPs on the workstation are simpler and avoid extra moving parts. But if you plan to grow the lab (more workstations, Kali attack box), install DHCP on the DC and authorize it in AD:

Install-WindowsFeature DHCP -IncludeManagementTools
Add-DhcpServerInDC -DnsName "dc01.lab.local" -IPAddress 10.10.10.10
Add-DhcpServerv4Scope -Name "LabScope" -StartRange 10.10.10.100 -EndRange 10.10.10.200 -SubnetMask 255.255.255.0
Set-DhcpServerv4OptionValue -DnsServer 10.10.10.10 -Router 10.10.10.1

If you use DHCP, make sure the scope hands out 10.10.10.10 as DNS — a workstation that resolves via an external DNS server will never find the domain.

Step 3 — Join WS01 to the domain

Boot WS01 and configure networking. Set the DC as its DNS server:

New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 10.10.10.50 -PrefixLength 24 -DefaultGateway 10.10.10.1
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 10.10.10.10

Confirm connectivity to the DC first — ping and an LDAP port check:

ping dc01.lab.local

Pinging dc01.lab.local [10.10.10.10] with 32 bytes of data:
Reply from 10.10.10.10: bytes=32 time<1ms TTL=128

Join the domain from PowerShell (run as local Administrator):

Add-Computer -DomainName "lab.local" -Credential (Get-Credential) -Restart

PowerShell credential request
Enter your credentials.
User: LABAdministrator
Password for user LABAdministrator: ********

WARNING: The changes will take effect after you restart the computer WS01.

Alternatively, use the GUI: Settings → System → About → Domain or workgroup → Change, enter lab.local and domain credentials. Either method works; PowerShell is scriptable and repeatable. WS01 reboots, then log in with LABAdministrator or any domain account.

Step 4 — Verify the domain join

The classic, fastest check is nltest, which queries the domain’s secure channel:

nltest /sc_query:lab.local

Flags: 30 HAS_IP  HAS_NAME
Trusted DC Connection Status Status = 0x0 NERR_Success
Trust Revision = 1
The command completed successfully
nltest /dsgetdc:lab.local

           DC: \DC01.lab.local
      Address: \10.10.10.10
     Dom Guid: 5e8f2c41-...
     Dom Name: LAB
  Forest Name: lab.local
 ...The command completed successfully

On the DC, enumerate domain users and computers to confirm objects landed where expected:

Get-ADUser -Filter * | Select-Object Name, SamAccountName

Name          SamAccountName
----          --------------
Administrator Administrator
Guest         Guest
krbtgt        krbtgt
Get-ADComputer -Filter * | Select-Object Name, DNSHostName

Name  DNSHostName
----  -----------
DC01  DC01.lab.local
WS01  WS01.lab.local

Step 5 — Create OUs, users, and groups

Structure matters. Real environments (and attack tools like BloodHound) reward you for mirroring a realistic OU hierarchy. Create a simple, sane structure:

New-ADOrganizationalUnit -Name "Corp" -Path "DC=lab,DC=local"
New-ADOrganizationalUnit -Name "Users"  -Path "OU=Corp,DC=lab,DC=local"
New-ADOrganizationalUnit -Name "Groups" -Path "OU=Corp,DC=lab,DC=local"
New-ADOrganizationalUnit -Name "Computers" -Path "OU=Corp,DC=lab,DC=local"
New-ADOrganizationalUnit -Name "ServiceAccounts" -Path "OU=Corp,DC=lab,DC=local"

Create a security group and a few users:

New-ADGroup -Name "Corp-Staff" -GroupScope Global -GroupCategory Security -Path "OU=Groups,OU=Corp,DC=lab,DC=local"

$users = "jdoe","asmith","bwu","svc_sql"
foreach ($u in $users) {
  New-ADUser -Name $u `
    -SamAccountName $u `
    -UserPrincipalName "$u@lab.local" `
    -Path "OU=Users,OU=Corp,DC=lab,DC=local" `
    -AccountPassword (ConvertTo-SecureString "C0mpl3x-P@ss!" -AsPlainText -Force) `
    -Enabled $true
}

Add users to the group and move WS01 into the Computers OU:

Add-ADGroupMember -Identity "Corp-Staff" -Members "jdoe","asmith","bwu"
Get-ADGroupMember -Identity "Corp-Staff" | Select-Object Name

Name
----
jdoe
asmith
bwu

Get-ADComputer WS01 | Move-ADObject -TargetPath "OU=Computers,OU=Corp,DC=lab,DC=local"

Log out of WS01 and back in as LABjdoe to confirm a standard user can authenticate. That’s a working domain.

Step 6 — Snapshot your baseline

Before anything else, shut both VMs down and take VirtualBox snapshots named lab-baseline-clean. Every destructive experiment — malware detonation, privilege escalation testing, misconfiguration injection — should happen on a linked clone or branch you can revert. This single habit saves more lab time than any other tip.

Three hardening notes for your lab (and real networks)

1. Deploy Windows LAPS

By default, every domain-joined machine’s local Administrator password is identical — a single credential dump compromises every workstation. Windows LAPS (native in Server 2019+ / Windows 10 20H2+ with April 2023 updates) auto-rotates a unique local admin password per machine, stored in AD with access control and expiration. In the lab, enable it and read the password with Get-LapsADPassword -Identity WS01 to see how it works before deploying it for real.

2. Practice tiered administration

Never log into a workstation with a Domain Admin account — credential theft on that machine now owns your whole domain. Build a tier model in your lab: Tier 0 (DC/domain admin) accounts only touch the DC, Tier 1 (server admins) only servers, Tier 2 (helpdesk) only workstations. Use separate admin accounts (jdoe-admin) rather than the daily driver account, and enable Protected Users group membership or “Account is sensitive and cannot be delegated” for privileged accounts.

3. Snapshot discipline

Snapshots are powerful and dangerous. Take a clean snapshot after every intentional configuration change; revert rather than “fixing” broken states. Never run a production-like environment with years-old snapshots containing stale credentials. And remember: if you snapshot a DC, old snapshots can cause USN rollback when restored — snapshot the lab before promotion when possible, or accept a rebuild if a DC snapshot goes sideways.

Defender takeaways

Knowledge check

  1. Why must WS01’s DNS server be set to 10.10.10.10 (the DC) before attempting the domain join, and what records does DNS provide that make the join succeed?
  2. What does nltest /sc_query:lab.local verify about WS01, and how does it differ from simply pinging the DC?
  3. You’re asked to create a service account for a SQL server. Which OU should it live in, and why should it be separate from regular user accounts?
  4. A colleague restores last year’s DC snapshot to “fix” a lab problem. What are two risks with that approach, and what should they do instead?
HMMNM Security · Independent security research and education · hmmnm.com
Printed from https://hmmnm.com/build-a-two-vm-active-directory-lab-domain-controller/
© 2026 HMMNM Security. For personal and internal team use. Please link to the original article when sharing.