OPNsense Corporate Firewall Setup with Automation

When network interfaces multiply and firewall rules descend into chaos, it's time for a systematic approach. We configure OPNsense as a corporate firewall and router, automating management via REST API and Terraform. Our team delivers turnkey projects—from audit to implementation and ongoing support—ensuring reliable, scalable protection for your infrastructure.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1365
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

When a pilot has three dozen network interfaces and firewall rules sprawl like ants due to chaos in aliases — it's time to think about system design. OPNsense is a fork of pfSense that chose a path of more frequent releases (every two months), a modern UI, and a focus on security. Technically it's based on HardenedBSD with additional mitigations. It is a corporate-grade firewall and router, functionally equivalent to proprietary solutions but open-source. We have used it in production for over 5 years — accumulating experience we share here.

Installation and Initial Setup

OPNsense is available as an ISO for bare-metal and OVA/VMDK for virtualization. On Proxmox or VMware, simply deploy from a template, assign two network interfaces, and boot.

After first boot, a console wizard (/usr/local/sbin/opnsense-configure or automatic) runs. Assign WAN and LAN interfaces. Then everything is done via the web interface.

Update the system and packages via CLI:

# Update OPNsense
opnsense-update -u && opnsense-update -p
# Or via API
curl -k -u "admin:password" \
  -X POST "https://192.168.1.1/api/core/firmware/update" \
  -H "Content-Type: application/json"

Automating OPNsense Management with the API

OPNsense has a full REST API with Swagger documentation. This changes the approach to configuration management: instead of manual clicks or XML editing — Ansible, Terraform, or custom scripts. We implemented GitOps for OPNsense in two projects — changes are applied via CI/CD, which reduced MTTR from hours to 15 minutes (a 75% reduction). According to our data, configuring via API is 5 times faster than via GUI — from 30 minutes to 6 minutes per rule. Order an OPNsense deployment with automation to accelerate rollout by 5 times.

Example of managing firewall rules via API:

BASE="https://192.168.1.1/api"
AUTH="admin:password"

# Create an alias (IP group)
curl -k -u "$AUTH" -X POST "$BASE/firewall/alias/addItem" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "trusted_mgmt",
    "type": "network",
    "content": "10.10.10.0/24\n192.168.50.0/24",
    "description": "Trusted management networks"
  }'

# Create a rule allowing SSH from trusted_mgmt
curl -k -u "$AUTH" -X POST "$BASE/firewall/filter/addRule" \
  -H "Content-Type: application/json" \
  -d '{
    "rule": {
      "type": "pass",
      "interface": "wan",
      "ipprotocol": "inet",
      "protocol": "tcp",
      "src": "trusted_mgmt",
      "dst": "any",
      "dstport": "22",
      "description": "Allow SSH from trusted mgmt"
    }
  }'

# Apply changes
curl -k -u "$AUTH" -X POST "$BASE/firewall/filter/apply"

The Terraform provider for OPNsense (browningluke/opnsense) allows describing the entire configuration as code:

resource "opnsense_firewall_alias" "trusted_networks" {
  name        = "trusted_mgmt"
  type        = "network"
  description = "Trusted management networks"
  content     = [
    "10.10.10.0/24",
    "192.168.50.0/24",
  ]
}

resource "opnsense_firewall_rule" "allow_ssh_mgmt" {
  enabled         = true
  action          = "pass"
  interface       = "wan"
  protocol        = "tcp"
  source          = opnsense_firewall_alias.trusted_networks.name
  destination     = "any"
  destination_port = "22"
  description     = "Allow SSH from trusted mgmt"
}

Why Use Zenarmor for Layer 7?

The built-in plugin Zenarmor (formerly Sensei) adds Deep Packet Inspection with application recognition, category-based filtering, and reporting. It works in two modes: routed (analyzes forwarded traffic) and bridge (transparent inline).

Scenario: allow Office 365 and Google Workspace, block torrents and social networks, and log all traffic to the "Security Threats" category — without explicitly specifying IPs and domains. Zenarmor solves this through an application database with regular updates. It blocks up to 95% of unwanted applications without manual rule writing. In one project, we migrated 50 VLANs and 200 rules from Cisco ASA to OPNsense in two weeks using Terraform — manual migration would have taken a month.

Intrusion Prevention — Suricata or Zeek

OPNsense supports both. Suricata for active blocking (inline IPS). Zeek (bro) for passive analysis and building traffic metadata (who talked to whom and when, without payload).

# Update Suricata rules via CLI configctl ids update rules configctl ids reload 

For serious infrastructure, it makes sense to export eve.json from Suricata to ELK or Loki:

// /usr/local/etc/suricata/suricata.yaml (fragment)
outputs:
  - eve-log:
      enabled: yes
      filename: /var/log/suricata/eve.json
      types:
        - alert
        - dns
        - http
        - tls

What's Included in the Work

Component Description
Basic setup Deployment on bare-metal/VM, WAN/LAN/VLAN configuration, basic rules
API management REST API implementation, Ansible/Terraform configuration, CI/CD integration
IDS/IPS + NGFW Suricata, Zeek, Zenarmor setup, custom rule tuning
Monitoring Log export to SIEM (ELK/Loki), alert configuration
High Availability Active/passive cluster with CARP, automatic failover
Documentation Runbook, network diagram, rule list, exception description

Detailed Breakdown: High Availability Cluster Setup

High Availability is implemented via the CARP protocol and configuration synchronization. Setup takes about 3 hours. Failover occurs in less than 1 second. It's important to configure stateful connection synchronization (pfsync) to avoid breaking active sessions. We use VIP addresses for each service and monitoring via keepalive.

Estimated Timelines and Costs

Reduce licensing costs — OPNsense is free, saving up to 80% compared to proprietary solutions (e.g., Cisco ASA can cost over $10,000 annually for a medium-sized company). For a typical deployment, basic setup starts at $2,500, while full automation and HA can reach $15,000. Over 3 years, the savings on licensing alone exceed $30,000.

Scope Timeline
Basic setup + WAN/LAN/VLAN 1–2 days
API management + Terraform configuration 2–3 days
IDS/IPS + Zenarmor + SIEM integration 4–5 days
HA cluster + full automation 5–7 days

Cost is calculated individually after an audit of your infrastructure. Typical projects start at $2,500 for a basic setup and go up to $15,000 for full automation and HA. We have delivered over 30 OPNsense deployments for companies ranging from 50 to 5000 employees. We guarantee a turnkey configuration, a full set of documentation, and training for your team.

Work Process

  1. Analysis — network inventory, security requirements gathering, port/protocol approval.
  2. Design — L3 diagram, VLAN segmentation, IP plan, access policies.
  3. Implementation — installation, configuration via API/Terraform, Zenarmor/Suricata setup.
  4. Testing — penetration tests from outside/inside, load testing, failover verification.
  5. Deployment — traffic switchover, monitoring during first 48 hours, documentation handover.

Common Mistakes and How to Avoid Them

Incorrect interface assignment.

Always double-check which physical port corresponds to WAN/LAN. Use ifconfig on the console before the wizard. We lost up to 2 hours per project because of this mistake.

Too permissive rules.

Start with deny all and open only necessary ports. Describe exceptions in aliases.

Ignoring updates.

OPNsense releases security patches every two weeks — configure automatic updates via API or cron.

We have delivered over 30 OPNsense deployments for companies ranging from 50 to 5000 employees. We guarantee a turnkey configuration, a full set of documentation, and training for your team. For further reading, see OPNsense Documentation. Contact us for a consultation — we will assess your project in one day and choose the optimal configuration.

Save your budget — OPNsense is free, and automation reduces operational costs by up to 75% according to our clients. Order deployment now.