Red Team Home Lab: Network Architecture

Sep 22, 2026/12 min read/10 sections

Why the network comes first

Most people build a lab as "a bunch of VMs on one bridge" and call it a day. A flat lab network is both a liability and a bad teacher. Two problems it creates immediately:

  1. Malware escape. Victim machines share your home LAN. Anything you detonate — a beacon, a ransomware sample, a noisy C2 — can reach your router, your NAS, your actual machines. That is how labs burn people.
  2. Unrealistic topology. Real engagements have a perimeter and an interior. You attack a exposed service, pivot, and land on an internal network that has no direct route back to you. A flat network teaches you nothing about pivoting, because there is nothing to pivot through.

So the router is the first thing I build, before any victim exists. The design goals:

  • Two lab segments that mimic a corporate estate: an "external" segment (192.168.100.0/24) where exposed services live, and an "internal" segment (192.168.200.0/24) behind it for the domain, workstations, and everything worth pivoting to.
  • No accidental egress. Victim machines get no internet by default. Segments cannot talk to each other unless I explicitly allow it.
  • Remote access. I attack over WireGuard from my laptop, full tunnel, from anywhere in the house — or anywhere at all.

Why a CT, not a VM

Routing is I/O-bound, not CPU-bound. The whole job is forwarding packets and running three small daemons (WireGuard, dnsmasq, iptables). Alpine Linux does that in a container with a fraction of what a VM would ask for:

TypeImageStorageRAM
CTAlpine1 GB256 MB

Every megabyte I don't burn on plumbing goes to victim machines — and those are the things that actually need RAM. I only reach for a VM-based router when I need something the kernel in a CT can't do, like running Suricata on a mirror port. This isn't that lab.

The design

One Alpine CT with four interfaces sits between everything:

InterfaceNetworkRole
eth0172.30.1.77/24Uplink into the home LAN
wg010.0.0.1/24WireGuard tunnel for my devices
eth1192.168.100.1/24"External" lab segment (DHCP)
eth2192.168.200.1/24"Internal" lab segment (DHCP)
flowchart TD
    subgraph home["Home Network — 172.30.1.0/24"]
        rtr["Home Router"]
        d1["Attacker Laptop — Kali"]
        d2["Proxmox Host"]
    end
 
    subgraph pve["Proxmox VMs / CTs"]
        subgraph alpine["Alpine CT — Virtual Router"]
            nic1["eth0 — 172.30.1.77/24"]
            wgn["wg0 — 10.0.0.1/24"]
            nic3["eth1 — 192.168.100.0/24"]
            nic4["eth2 — 192.168.200.0/24"]
        end
        subgraph victims["Victim Machines"]
            vm1["Windows A — 192.168.100.2"]
            vm2["Linux A — 192.168.100.3"]
            vm3["Linux B — 192.168.200.2"]
            vm4["Windows B — 192.168.200.3"]
        end
    end
 
    rtr -- "172.30.1.33" --> d1
    rtr -- "172.30.1.44" --> d2
    d2 -- "mgmt" --> nic1
    d1 -- "WireGuard" --> wgn
    wgn -- "allow" --> nic3
    wgn -- "allow" --> nic4
    nic3 -- "192.168.100.2" --> vm1
    nic3 -- "192.168.100.3" --> vm2
    nic4 -- "192.168.200.2" --> vm3
    nic4 -- "192.168.200.3" --> vm4

One thing to get right before writing any firewall rules: interface names inside the CT follow the order you attach the network devices in Proxmox, not any fixed convention. Run ip addr on the CT first and map ethX to segment on your box — getting this backwards means your "isolation" rules isolate nothing.

Proxmox side: the bridges

Each lab segment needs a Linux bridge on the Proxmox host — think of them as virtual switches. vmbr1 carries the external segment:

Proxmox — creating vmbr1, the bridge for the external lab segment, with the host at 192.168.100.2/24

The host takes 192.168.100.2/24 on this bridge. That's deliberate: it puts the Proxmox host itself inside the external segment's broadcast domain, so I can reach victim consoles and test services from the host without routing. No gateway is set — the lab segment is not a place the host should route through.

Then the router CT's network device is attached to vmbr1 with a static address, because this CT is the segment's gateway and DHCP server:

Proxmox — the router CT's veth attached to vmbr1 with a static 192.168.100.1/24

Create a second bridge, vmbr2, for the internal segment the same way. I leave vmbr2 without an IP on the host — pure L2. The internal segment should be reachable only through the router; giving the host a foot in it defeats the point.

WireGuard with PiVPN

WireGuard gives me two things a console-only setup can't: I can attack from my laptop without being in the rack room, and the attacker box routes into the lab full-tunnel — every tool sees the lab's networks as directly attached.

PiVPN automates the boring parts (key generation, server config, client provisioning). Its main branch only supports Debian; Alpine support lives in the test branch:

curl https://raw.githubusercontent.com/pivpn/pivpn/test/auto_install/install.sh | bash

The installer writes its answers to /etc/pivpn/wireguard/setupVars.conf. These are the values that matter for this build:

# /etc/pivpn/wireguard/setupVars.conf (trimmed to the interesting lines)
PLAT=Alpine
OSCN=3.22.5
USING_UFW=0
IPv4dev=eth0
VPN=wireguard
pivpnPORT=51820
pivpnDNS1=1.1.1.1
pivpnDNS2=1.0.0.1
pivpnHOST=172.30.1.77
pivpnPROTO=udp
pivpnMTU=1420
pivpnDEV=wg0
pivpnNET=10.0.0.0
subnetClass=24
pivpnenableipv6=0
ALLOWED_IPS="0.0.0.0/0, ::0/0"

ALLOWED_IPS=0.0.0.0/0 makes client tunnels full-tunnel — everything from my laptop goes into the lab, which is what I want during an engagement. pivpnMTU=1420 leaves room for WireGuard's overhead on a 1500-byte uplink. Adding a client later is pivpn add, then pivpn -qr for a QR code to scan into the mobile client.

The generated server config needs one addition. Out of the box, WireGuard only moves packets between peers on wg0 itself — it does not route tunnel clients into the lab's other subnets:

# /etc/wireguard/wg0.conf
[Interface]
PrivateKey = <server-private-key>   # yours comes from the installer — never reuse one
Address = 10.0.0.1/24
MTU = 1420
ListenPort = 51820
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;

PostUp and PostDown are the important part. When wg0 comes up they install two forwarding rules — traffic may enter and leave the tunnel — plus a MASQUERADE rule that NATs tunnel traffic out eth0, so my laptop keeps internet access through the lab while connected. When wg0 goes down, everything is removed cleanly, leaving no stale rules behind.

DHCP with dnsmasq

Both lab segments need a DHCP server so victim machines just work when they boot. dnsmasq is the right tool — it's a single binary with a single config file:

apk add dnsmasq
# /etc/dnsmasq.conf — one block per lab segment
 
# External segment
interface=eth1
dhcp-range=192.168.100.100,192.168.100.150,12h
 
# Internal segment
interface=eth2
dhcp-range=192.168.200.100,192.168.200.150,12h
 
# Static reservations for fixed roles — by hostname or MAC
dhcp-host=Sysreptor,192.168.100.3

Two deliberate choices here. Both lab interfaces are listed explicitly, so DHCP is bound to exactly them — a DHCP server listening on the uplink would fight your home router for leases, which is a great way to annoy everyone else in the house. And DHCP-managed doesn't have to mean random: workstations can live off the pool, but anything with a fixed role — a domain controller, a web server the whole lab depends on — gets a dhcp-host reservation. A domain controller whose IP drifts between reboots is a bad time.

Make it survive reboots, and enable forwarding so the CT can actually route:

rc-service dnsmasq start && rc-update add dnsmasq
echo "net.ipv4.ip_forward=1" | tee -a /etc/sysctl.conf && sysctl -p

ip_forward=1 is easy to forget and fatal to skip: without it the kernel silently drops everything it's supposed to route, and you spend an evening wondering why the VPN connects but nothing is reachable.

The firewall: controlling the lab

Now the part that makes this a lab and not just a network. The script below is the whole policy in one place: segments are isolated from each other, internet access is a per-segment toggle, and the default posture is deny.

#!/bin/sh
# /etc/lab/firewall.sh
IPT=iptables
 
# defaults — overridden by --lan1=1 / --lan2=1 flags
LAN1_INTERNET="${LAN1_INTERNET:-0}"
LAN2_INTERNET="${LAN2_INTERNET:-0}"
 
ACTION="$1"
shift 2>/dev/null
 
for arg in "$@"; do
    case "$arg" in
        --lan1=*) LAN1_INTERNET="${arg#*=}" ;;
        --lan2=*) LAN2_INTERNET="${arg#*=}" ;;
    esac
done
 
add_rule() {
    $IPT -C "$@" 2>/dev/null || $IPT -A "$@"
}
remove_rule() {
    $IPT -C "$@" 2>/dev/null && $IPT -D "$@"
}
 
apply() {
    $IPT -P FORWARD DROP
 
    # segment isolation — always on
    add_rule FORWARD -i eth1 -o eth2 -j DROP
    add_rule FORWARD -i eth2 -o eth1 -j DROP
 
    # LAN1 (external segment) internet toggle
    if [ "$LAN1_INTERNET" = "1" ]; then
        add_rule FORWARD -i eth1 -o eth0 -j ACCEPT
        add_rule FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
        # NAT is required: the home router would drop RFC1918 sources otherwise
        add_rule -t nat POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
    else
        remove_rule FORWARD -i eth1 -o eth0 -j ACCEPT
        remove_rule FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
        remove_rule -t nat POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
    fi
 
    # LAN2 (internal segment) internet toggle
    if [ "$LAN2_INTERNET" = "1" ]; then
        add_rule FORWARD -i eth2 -o eth0 -j ACCEPT
        add_rule FORWARD -i eth0 -o eth2 -m state --state ESTABLISHED,RELATED -j ACCEPT
        add_rule -t nat POSTROUTING -s 192.168.200.0/24 -o eth0 -j MASQUERADE
    else
        remove_rule FORWARD -i eth2 -o eth0 -j ACCEPT
        remove_rule FORWARD -i eth0 -o eth2 -m state --state ESTABLISHED,RELATED -j ACCEPT
        remove_rule -t nat POSTROUTING -s 192.168.200.0/24 -o eth0 -j MASQUERADE
    fi
 
    echo "Applied: LAN1_INTERNET=$LAN1_INTERNET LAN2_INTERNET=$LAN2_INTERNET"
}
 
cleanup() {
    remove_rule FORWARD -i eth1 -o eth2 -j DROP
    remove_rule FORWARD -i eth2 -o eth1 -j DROP
    remove_rule FORWARD -i eth1 -o eth0 -j ACCEPT
    remove_rule FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
    remove_rule FORWARD -i eth2 -o eth0 -j ACCEPT
    remove_rule FORWARD -i eth0 -o eth2 -m state --state ESTABLISHED,RELATED -j ACCEPT
    remove_rule -t nat POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
    remove_rule -t nat POSTROUTING -s 192.168.200.0/24 -o eth0 -j MASQUERADE
 
    $IPT -P FORWARD ACCEPT
 
    echo "Cleaned up. FORWARD policy restored to ACCEPT, lab rules removed."
}
 
status() {
    echo "--- FORWARD chain ---"
    $IPT -L FORWARD -v -n --line-numbers
    echo ""
    echo "--- Summary ---"
 
    POLICY=$($IPT -L FORWARD | head -1 | grep -o 'policy [A-Z]*' | awk '{print $2}')
    echo "FORWARD policy: $POLICY"
 
    if $IPT -C FORWARD -i eth1 -o eth2 -j DROP 2>/dev/null; then
        echo "LAN1 <-> LAN2 isolation: ACTIVE"
    else
        echo "LAN1 <-> LAN2 isolation: NOT SET"
    fi
 
    if $IPT -C FORWARD -i eth1 -o eth0 -j ACCEPT 2>/dev/null; then
        echo "LAN1 internet: OPEN"
    else
        echo "LAN1 internet: CLOSED"
    fi
 
    if $IPT -C FORWARD -i eth2 -o eth0 -j ACCEPT 2>/dev/null; then
        echo "LAN2 internet: OPEN"
    else
        echo "LAN2 internet: CLOSED"
    fi
}
 
case "$ACTION" in
    apply)   apply ;;
    cleanup) cleanup ;;
    status)  status ;;
    *)
        echo "Usage: $0 {apply|cleanup|status} [--lan1=0|1] [--lan2=0|1]"
        echo "  apply     apply isolation + internet toggle rules"
        echo "  cleanup   remove all rules, restore ACCEPT policy"
        echo "  status    show current FORWARD chain + toggle summary"
        exit 1
        ;;
esac

Design notes worth stealing:

  • Default-deny first. iptables -P FORWARD DROP means anything not explicitly allowed is dropped. The two explicit DROP rules between segments look redundant under a DROP policy, but they're insurance: if someone (future me) flips the policy back to ACCEPT, isolation survives.
  • Internet is opt-in per segment. Most of the time both toggles are 0. Victim boxes that need internet during setup get it for an hour, then it goes off again. Malware that phones home finds a dead end.
  • Idempotent by construction. Every mutation is guarded by -C, so running apply ten times leaves one copy of each rule — this matters because the script runs at every boot.
  • cleanup exists for a reason. When I want the lab wide open for a specific test, one command restores an ACCEPT policy and removes everything — no half-remembered manual iptables surgery.

Usage during a build weekend looks like:

/etc/lab/firewall.sh apply --lan1=1    # external segment needs internet for updates
/etc/lab/firewall.sh apply             # back to lockdown
/etc/lab/firewall.sh status

Surviving reboots — Alpine/OpenRC

The script lives in /etc/lab/firewall.sh. To run it at boot, Alpine's convention is a script under /etc/local.d — everything ending in .start there is executed by the local OpenRC service, which starts late in the boot sequence, after networking is up. That ordering is exactly what a firewall bootstrap needs: no interfaces, no rules.

# Step 1: create the bootstrap script
cat > /etc/local.d/lab-firewall.start <<'EOF'
#!/bin/sh
/etc/lab/firewall.sh apply
EOF
 
# Step 2: make it executable
chmod +x /etc/local.d/lab-firewall.start
 
# Step 3: enable the local service
rc-update add local default

The <<'EOF' heredoc matters — quoting the delimiter prevents shell expansion inside the block, so the generated file is exactly the two lines you want.

Trust, but verify

The moment of truth:

Router:~# /etc/lab/firewall.sh status
--- FORWARD chain ---
Chain FORWARD (policy DROP 488 packets, 30744 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 DROP       all  --  eth1   eth2    0.0.0.0/0            0.0.0.0/0
2        0     0 DROP       all  --  eth2   eth1    0.0.0.0/0            0.0.0.0/0
3     1818 1404K ACCEPT     all  --  wg0    *       0.0.0.0/0            0.0.0.0/0
4     1947 1448K ACCEPT     all  --  *      wg0     0.0.0.0/0            0.0.0.0/0
 
--- Summary ---
FORWARD policy: DROP
LAN1 <-> LAN2 isolation: ACTIVE
LAN1 internet: CLOSED
LAN2 internet: CLOSED
Router:~#

Reading it: policy is DROP and 488 packets have already died on it — that counter going up is your isolation working. Rules 3 and 4 are the WireGuard PostUp accepts, and the megabytes flowing through them are attack traffic from the laptop into the lab. Segments isolated, no internet, VPN in — exactly the posture I want before a single victim exists.

Where this leaves the lab

The foundation is done: two isolated segments, a router that policies everything, DHCP on the external segment, and remote access over WireGuard from anywhere. From here the lab is ready for victims — Windows and Linux templates go on the two segments, and everything that follows (the AD stack, attack tooling, logging) assumes this network is underneath it.