← Back to Labs / OPNsense

All-in-One AI Server Architecture: OPNsense, Ollama & Docker on One Host

OpsNexusAI Engineering •
14 min read

Overview

Combining firewall routing, container orchestration, vector databases, and GPU LLM inference on a single physical host reduces physical hardware footprint and power consumption. However, running OPNsense virtualized alongside Linux Docker workloads requires strict Proxmox VE hypervisor tuning, SR-IOV / PCIe GPU passthrough, and isolated virtual bridge switches (vmbr0, vmbr1).

This guide details the exact production architecture for building a single-host sovereign AI server without compromising security or GPU performance.


Single-Host Hypervisor Architecture

┌────────────────────────────────────────────────────────────────────────┐
│                      PROMOX VE BARE-METAL HOST                         │
│                                                                        │
│  ┌──────────────────────────────┐      ┌────────────────────────────┐  │
│  │ OPNsense VM (FreeBSD)        │      │ Linux AI Compute Host (VM) │  │
│  │ - WAN: Physical Port igc0    │      │ - Docker Engine 26.x      │  │
│  │ - LAN Gateway: 10.10.0.1     │      │ - NVIDIA PCIe Passthrough  │  │
│  │ - VLAN 20 (AI Apps): 10.20.0 │ ────►│ - Ollama & vLLM Containers│  │
│  └──────────────────────────────┘      └────────────────────────────┘  │
│                 ▲                                   ▲                  │
│                 └────────── Virtual Bridge ─────────┘                  │
└────────────────────────────────────────────────────────────────────────┘

Step 1: Proxmox VE Virtual Bridge & IOMMU Configuration

To pass your NVIDIA GPU to the Linux AI guest VM while running OPNsense on virtual interfaces, enable IOMMU in the host bootloader.

Edit /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt initcall_blacklist=sysfb_init"

Update GRUB and reload kernel modules:

sudo update-grub
echo "vfio" | sudo tee -a /etc/modules
echo "vfio_iommu_type1" | sudo tee -a /etc/modules
echo "vfio_pci" | sudo tee -a /etc/modules
sudo update-initramfs -u -k all

Step 2: Proxmox Virtual Network Interfaces (/etc/network/interfaces)

Configure Linux bridge interfaces in Proxmox to trunk VLANs between OPNsense and Docker:

auto lo
iface lo inet loopback

iface enp3s0 inet manual

# Physical WAN Port -> Handed over to OPNsense
iface enp4s0 inet manual

# Internal Virtual Trunk Bridge
auto vmbr0
iface vmbr0 inet manual
	bridge-ports enp3s0
	bridge-stp off
	bridge-fd 0
	bridge-vlan-aware yes
	bridge-vids 10 20 30

Step 3: Docker Isolated Stack Deployment

Inside the Linux AI Compute VM (10.20.0.10), deploy your inference stack bound to internal interfaces:

version: "3.8"

services:
  ollama_engine:
    image: ollama/ollama:latest
    container_name: all_in_one_ollama
    restart: unless-stopped
    ports:
      - "127.0.0.1:11434:11434"
    volumes:
      - /opt/ollama:/root/.ollama
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

  open_webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: all_in_one_webui
    restart: unless-stopped
    environment:
      - OLLAMA_BASE_URL=http://127.0.0.1:11434
    ports:
      - "10.20.0.10:8080:8080"
    depends_on:
      - ollama_engine

Single-Host Performance Benchmarks

MetricDirect Bare MetalProxmox Virtualized AI ServerPerformance Impact
GPU Inference Speed (Llama 3 8B)84.2 tok/s83.6 tok/s< 0.7% Loss
Inter-VM Network Latency (virtio)N/A0.12 msNear Line Speed
OPNsense Firewall Throughput9.4 Gbps9.1 GbpsMinimal CPU Overhead

Failure Modes & Recovery Actions

  1. GPU BAR1 Memory Exhaustion on VM Boot: If Proxmox fails to allocate PCIe memory to the guest VM, enable above4G and hostpci0: x-vga=on in /etc/pve/qemu-server/<vmid>.conf.
  2. OPNsense Boot Order Deadlock: Ensure OPNsense VM (VMID 100) is configured with boot: order=cdn and starts before the AI Compute VM (VMID 101) to establish gateway routing.

FreeBSD Kernel Tuning for OPNsense Virtualization

When running OPNsense as a guest VM inside Proxmox alongside Linux AI containers, tune OPNsense kernel parameters to ensure high network throughput without consuming excessive host CPU cycles.

OPNsense System Tunables (/boot/loader.conf.local)

Navigate to OPNsense -> System -> Settings -> Tunables and set:

# Enable Fast Forwarding for Gigabit+ Routing
net.inet.ip.fastforwarding=1

# Increase Network Interface Memory Buffers
kern.ipc.nmbclusters="1000000"

# Disable Hardware Checksum Offloading on Virtual Interfaces
net.inet.tcp.tso=0

ZFS Memory Management Tuning on Host

Proxmox VE uses ZFS by default, which can consume up to 50% of host RAM for its ARC cache. On a server hosting both OPNsense and 32GB+ LLM models, cap ZFS memory usage to 8GB.

Create /etc/modprobe.d/zfs.conf:

# Cap ZFS ARC Memory to 8GB (8589934592 Bytes)
options zfs zfs_arc_max=8589934592

Reload ZFS module or reboot host to free system RAM for GPU inference.

System Architecture Blueprint

Building an all-in-one sovereign AI server requires virtualizing network routing (OPNsense) alongside heavy GPU container engine workloads (Docker / vLLM) on a single physical host.

Using Proxmox VE or Linux KVM with PCI passthrough, the physical WAN/LAN NICs are assigned directly to OPNsense, while local GPU containers reside on an isolated virtual bridge (vmbr1) behind the OPNsense firewall.

+-------------------------------------------------------------------------+
|                       Physical Host Machine                             |
|                                                                         |
|  +--------------------------------+   +------------------------------+  |
|  | OPNsense VM (Proxmox / KVM)   |   | Host Kernel / Docker Engine  |  |
|  |  - WAN NIC (PCI Passthrough)   |   |  - NVIDIA RTX / H100 GPU     |  |
|  |  - LAN Virtual Bridge (vmbr1)  |   |  - vLLM / Ollama Container   |  |
|  |  - WireGuard / Suricata IPS    |   |  - IP: 10.0.10.50 (Internal) |  |
|  +--------------------------------+   +------------------------------+  |
|                   ^                                  ^                  |
|                   |========== Virtual Bridge ========|                  |
+-------------------------------------------------------------------------+

Step 1: Virtual Network Interface Configuration (/etc/network/interfaces)

Configure the hypervisor host networking to route host container traffic strictly through OPNsense’s internal interface (10.0.10.1):

auto lo
iface lo inet loopback

iface enp3s0 inet manual # Physical WAN (Passed to OPNsense VM)
iface enp4s0 inet manual # Physical LAN (Passed to OPNsense VM)

# Internal Virtual AI Bridge
auto vmbr1
iface vmbr1 inet static
    address 10.0.10.50/24
    gateway 10.0.10.1
    bridge-ports none
    bridge-stp off
    bridge-fd 0

Step 2: OPNsense NAT & Port Forwarding Rules

Inside the OPNsense web management UI (10.0.10.1):

  1. Navigate to Firewall -> NAT -> Port Forward.
  2. Add a rule for incoming HTTPS traffic:
    • Interface: WAN
    • Protocol: TCP
    • Destination Port: 443
    • Redirect Target IP: 10.0.10.50 (Host Reverse Proxy / Caddy Container)
    • Redirect Target Port: 443

Step 3: Hardened Docker Compose Stack Behind OPNsense

Deploy services bound exclusively to the internal bridge IP (10.0.10.50):

version: "3.8"

services:
  caddy-entrypoint:
    image: caddy:2-alpine
    container_name: ai-gateway-caddy
    restart: always
    ports:
      - "10.0.10.50:80:80"
      - "10.0.10.50:443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data

  ollama-backend:
    image: ollama/ollama:latest
    container_name: local-ollama-gpu
    restart: always
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    expose:
      - "11434"

volumes:
  caddy_data:

OpsNexusAI Engineering

Verified Lab Publication

OpsNexusAI is a technical laboratory dedicated to sovereign AI infrastructure. Every implementation guide and architectural blueprint published here is tested on physical hardware and isolated networks. Our team specializes in the deployment of private LLMs, network hardening with OPNsense, and enterprise-grade automation patterns.


Join the OpsNexus Brief

Get technical teardowns on sovereign AI architectures delivered to your inbox.