Enterprise VLAN Segmentation with OPNsense on Hyper-V
Enterprise VLAN Segmentation with OPNsense on Hyper-V
From Flat Network to Fully Segmented, High-Availability Architecture
Executive Overview
Modern networks cannot afford to operate flat. Lateral movement, ransomware propagation, and credential harvesting thrive in environments where all systems share a broadcast domain.
This guide walks through:
-
Migrating from a flat network to VLAN segmentation
-
Deploying OPNsense on Hyper-V as a Layer 3 gateway
-
Implementing secure inter-VLAN firewall controls
-
Hardening the environment for production
-
Adding High Availability (CARP) for zero-downtime resilience
-
Operational readiness and lifecycle management
This is structured as a real-world deployment blueprint — suitable for SMB through enterprise environments.
Phase 1 – Understanding the Problem: The Flat Network
Most environments begin like this:
-
One subnet (e.g., 192.168.1.0/24)
-
One default gateway
-
All systems share the same broadcast domain
-
Firewall rules exist only at the WAN edge
Why This Is Dangerous
If one workstation becomes compromised:
-
It can scan all servers
-
It can attempt Kerberos/NTLM harvesting
-
It can reach management interfaces
-
It can move laterally without restriction
Flat networks maximize blast radius.
Segmentation reduces it.
Phase 2 – Designing the Segmentation Model
Before touching Hyper-V or OPNsense, design your VLAN structure intentionally.
Example Enterprise VLAN Layout
| VLAN | Purpose | Subnet |
|---|---|---|
| 10 | Management | 10.10.10.0/24 |
| 20 | Servers | 10.10.20.0/24 |
| 30 | Workstations | 10.10.30.0/24 |
| 40 | Voice | 10.10.40.0/24 |
| 50 | IoT | 10.10.50.0/24 |
| 60 | Guest | 10.10.60.0/24 |
Design Principles
-
Management isolated from users
-
IoT isolated from servers
-
Guest Internet-only
-
Explicitly allow east-west traffic
-
Default deny between VLANs
Segmentation is not about VLAN creation — it is about policy enforcement.
Phase 3 – Hyper-V Network Foundation
OPNsense will act as:
-
Layer 3 gateway
-
Inter-VLAN router
-
Firewall enforcement point
But Hyper-V must pass VLAN tags correctly.
Step 1 – Create External Virtual Switch
Bind to a trunked physical NIC:
New-VMSwitch -Name "External-Trunk" -NetAdapterName "Ethernet" -AllowManagementOS $false
Requirements
-
Physical switch port must be trunk
-
Required VLAN IDs allowed
-
No native VLAN reliance (preferred)
Step 2 – Trunk OPNsense VM NIC
Hyper-V must pass VLAN tags to OPNsense.
Set-VMNetworkAdapterVlan -VMName "OPNsense" -Trunk -AllowedVlanIdList "10,20,30,40,50,60" -NativeVlanId 1
This allows OPNsense to receive 802.1Q tags.
Step 3 – Assign VLANs to Other VMs
Each workload VM receives an Access VLAN:
Set-VMNetworkAdapterVlan -VMName "SQL01" -Access -VlanId 20
Never trunk non-firewall VMs unless absolutely required.
Hyper-V Design Considerations
Important Limitations
-
Hyper-V VLAN handling is less flexible than VMware
-
Internal vSwitches do not behave like full enterprise switches
-
Trunk must terminate at OPNsense
Security Best Practices
-
Do not enable trunk mode on non-firewall VMs
-
Avoid native VLAN usage
-
Place Hyper-V management NIC in Management VLAN
-
Restrict WinRM and remote access
Phase 4 – OPNsense Base Installation
-
Install OPNsense normally
-
Assign:
-
WAN → Internet interface
-
LAN → Trunk interface
-
-
Access GUI
-
Run setup wizard
-
Change admin password
-
Configure WAN
At this point you have a single LAN interface.
Now we build segmentation.
Phase 5 – Creating VLAN Interfaces in OPNsense
Step 1 – Create VLANs
Navigate:
Interfaces → Other Types → VLAN
Create VLANs on parent LAN interface:
-
VLAN 10 (MGMT)
-
VLAN 20 (SERVERS)
-
VLAN 30 (USERS)
-
VLAN 40 (VOICE)
-
VLAN 50 (IOT)
-
VLAN 60 (GUEST)
Step 2 – Assign Interfaces
Interfaces → Assignments
Add and rename properly:
-
MGMT
-
SERVERS
-
USERS
-
VOICE
-
IOT
-
GUEST
Naming clarity matters long-term.
Step 3 – Assign Gateway IPs
Example:
| VLAN | Gateway |
|---|---|
| 10 | 10.10.10.1 |
| 20 | 10.10.20.1 |
| 30 | 10.10.30.1 |
| 50 | 10.10.50.1 |
| 60 | 10.10.60.1 |
These will later become CARP VIPs in HA.
Step 4 – Configure DHCP (Where Appropriate)
-
No DHCP for MGMT (static only)
-
Yes for Users
-
Yes for IoT
-
Yes for Guest
Phase 6 – Firewall Policy Architecture
Default stance:
Deny everything between VLANs.
Allow only what is required.
Required Aliases
Create:
-
RFC1918
-
MGMT_HOSTS
-
CORE_SERVERS
-
INFRA_SERVICES
Aliases make rules readable and enforceable.
Example Rule Structure
Guest VLAN
-
Allow DNS to firewall
-
Allow 80/443 to WAN
-
Block (log) RFC1918
Internet only.
IoT VLAN
-
Allow DNS/NTP
-
Allow WAN access
-
Block MGMT
-
Block SERVERS
-
Log all internal attempts
Workstation VLAN
-
Allow DNS/NTP
-
Allow specific ports to CORE_SERVERS
-
Allow WAN
-
Block MGMT
-
Block IoT
Management VLAN
-
Allow MGMT_HOSTS to all internal VLANs
-
Allow firewall GUI access
-
Block WAN (unless required)
Restrict GUI under:
System → Settings → Administration
Egress Filtering
Instead of “any to WAN”:
Allow:
-
80/443
-
Required update ports
Block:
-
SMTP outbound
-
Unnecessary high-risk ports
Phase 7 – Performance Optimization
For enterprise deployments:
-
Use synthetic NICs only
-
4+ vCPU minimum
-
8–16 GB RAM recommended
-
Enable VMQ
-
Enable SR-IOV if supported
-
Disable Large Send Offload if using IDS
Monitor:
-
CPU
-
State table size
-
Interface drops
Phase 8 – High Availability (CARP on Hyper-V)
Production environments should not rely on a single firewall VM.
HA Architecture
Two Hyper-V hosts
Two OPNsense VMs
Dedicated SYNC network
Each VLAN has:
| Role | IP |
|---|---|
| FW-A | 10.10.20.2 |
| FW-B | 10.10.20.3 |
| CARP VIP | 10.10.20.1 |
Clients use VIP as gateway.
Critical Hyper-V Requirement
Enable MAC spoofing:
Set-VMNetworkAdapter -VMName "OPNsense-A" -MacAddressSpoofing On
Without this, CARP will fail.
SYNC Network
Create dedicated internal vSwitch:
New-VMSwitch -Name "OPNsense-Sync" -SwitchType Internal
Used for:
-
pfsync
-
Config sync
Never route this network.
CARP Configuration
-
Enable state + config sync
-
Assign SYNC interface
-
Create CARP VIPs per VLAN
-
Set advskew:
-
Primary = 0
-
Secondary = 100
-
Failover Testing
Test:
-
Manual maintenance mode
-
Hard power-off
-
ARP refresh behavior
-
Session persistence
Phase 9 – Zero-Downtime Upgrade Strategy
-
Upgrade BACKUP node first
-
Validate sync
-
Force failover
-
Upgrade former primary
-
Restore priority
Never upgrade both nodes simultaneously.
Always backup configs first.
Phase 10 – Troubleshooting Common CARP + Hyper-V Issues
CARP not becoming MASTER
→ Enable MAC spoofing.
Slow failover
→ Enable gratuitous ARP refresh.
States not syncing
→ Verify pfsync interface and firewall rules.
WAN CARP failing
→ ISP may block ARP spoofing.
Split-brain
→ Allow protocol 112 (CARP).
Phase 11 – Production Readiness Checklist
Infrastructure
☐ Two physical hosts
☐ UPS redundancy
☐ Switch redundancy
☐ Trunk parity confirmed
Networking
☐ Dedicated SYNC network
☐ VLAN documentation complete
☐ Outbound NAT uses CARP VIP
Security
☐ No “Allow Any Any” rules
☐ GUI restricted to MGMT
☐ IDS tested
☐ Logging enabled
HA
☐ Failover tested
☐ State sync verified
☐ Upgrade simulation completed
Monitoring
☐ SNMP enabled
☐ Alerts configured
☐ Syslog forwarding enabled
Final Architecture Outcome
You now have:
-
VLAN-segmented network
-
Controlled east-west traffic
-
Hyper-V optimized deployment
-
High-availability firewall layer
-
Zero-downtime upgrade capability
-
Production-grade operational controls
Flat networks are convenient.
Segmented, redundant, policy-driven networks are resilient.
Comments
Post a Comment
Got something to say? Drop a comment below — let’s chat!