← All guides

Home lab firewall basics: rules that protect without breaking services

Networking · 10 min read

A working home lab firewall ruleset is short: on each internal network, allow DNS to the gateway, block traffic to private (RFC1918) destinations, allow the internet, and then add named exceptions, one service, one port, one direction, above the block. That pattern, documented in current OPNsense segmentation guides, protects the lab without breaking its services because every allow is deliberate. Copying another lab's finished ruleset rarely works, because the exceptions are the personal part. Deriving the rules from a list of your own services takes about an hour and survives every change of hardware or layout.

Who this is for: a lab owner running OPNsense or pfSense, with VLANs already in place or planned. Who should skip it: anyone looking for a finished ruleset to paste in, there is not one here, on purpose. This guide is general information about firewall concepts and common configurations; a ruleset reduces exposure between networks, and no ruleset guarantees a network cannot be compromised.

The one idea: deny between networks, allow by exception

The baseline philosophy in the sourced guides is consistent: deny everything between VLANs by default, then allow specific exceptions. A VLAN, a virtual LAN, one separated segment of the local network, starts with no right to talk to any other VLAN. The firewall, the device that routes traffic between segments, decides each exception. That inversion is the whole model. A ruleset built on allows has to enumerate every bad destination to stay safe. A ruleset built on a default deny only has to enumerate the good ones, and a home lab has few of those: a media server reached from the TV network, a NAS reached from trusted computers, the firewall's own web interface reached from one management network.

Two defaults frame the work. On OPNsense, the default posture is permissive on the LAN and blocked on the WAN, and VLAN segmentation needs explicit rules, creating a VLAN alone segments nothing until rules say what may cross. And OPNsense evaluates rules top to bottom and stops at the first match. Order is therefore part of the policy, not a cosmetic detail: an allow rule placed below a block rule that already matches the same traffic is never reached.

Start from a service inventory, not a template

Published rulesets fail as templates for a simple reason: they encode someone else's services. One widely copied baseline assumes Trusted, Servers, and IoT segments; another numbers its VLANs differently. The segments are not the transferable part. The transferable part is the derivation, and it starts with a one-page inventory. For each service in the lab, write four facts:

ColumnWhat to writeExample shape
ServiceName and the machine or segment it runs onMedia server, on Servers
Who reaches itThe segments that legitimately use itTrusted and IoT (the TVs)
Port and directionThe specific port, and which side starts the connectionOne named port, inbound to Servers only
What it must never reachThe segments with no business case for contactManagement, in either direction

The example row is a shape, not a setting: the port belongs to the service in your lab, read from that service's own documentation. Fifteen minutes with this table produces something no template can, the complete list of exceptions the ruleset needs, and, just as useful, the list of traffic that should stay blocked because nobody wrote it down as needed. If a flow is not in the inventory, the default deny handles it, and a service that later breaks points straight back to a missing row.

The baseline ruleset, in order

Applied per VLAN, the documented baseline is three rules, in this order:

OrderRuleEffect
1Allow DNS to the gatewayDevices on the segment can resolve names through the firewall
2Block destinations in RFC1918 private address spaceThe segment cannot initiate contact with any other private network, the other VLANs and the LAN
3Allow the internetEverything not matched above, public addresses, is permitted

RFC1918 is the set of private address ranges used inside home and office networks, so rule 2 is the segmentation rule: it draws the boundary in a single line instead of one block per neighbouring VLAN. Rule 3 then grants the internet without reopening the lab, because private destinations have already matched rule 2 and stopped. Named exceptions slot in above rule 2, the next section covers those. Rules that must never be reordered are 2 and 3: swap them, and the internet allow matches private destinations first, and the block stops meaning anything.

Check the version before trusting any DHCP step

One version detail silently breaks older guides. In OPNsense 26.1, Dnsmasq is the default DHCP and DNS provider for new installs, and existing ISC DHCP leases do not migrate automatically. A segmentation guide written against older releases will point at ISC DHCPv4 menus that a fresh 26.1 install does not use the same way. The rule logic is version-independent; the DHCP screens are not. Before following any DHCP instruction, here or anywhere, confirm which provider the installed version runs, and treat a mismatch as a version difference first, not a mistake in the rules.

InstallDefault DHCP/DNS providerPractical consequence
OPNsense 26.1, new installDnsmasqFollow Dnsmasq DHCP steps for the new segment
Install carried over from ISC DHCPISC DHCP configuration in placeLeases do not migrate automatically if the provider is changed

Exceptions: giving a service exactly one door

An exception is a single allow rule with three narrow fields: one source segment, one destination, one port. The documented pattern gives two reference points. The Trusted VLAN reaches the Servers VLAN on specific ports, not the whole segment, not all ports. And nothing initiates a connection to the Management VLAN except Trusted, and then only on the firewall web UI port. Management is the segment that administers the network gear itself, so it accepts the fewest doors of all.

Placement decides whether an exception exists at all. Because evaluation stops at the first match, every exception must sit above the block-RFC1918 rule for its segment. An exception saved below that block is a common silent failure: the rule is present, the settings page shows it, and the traffic still dies at the block above it. After adding any exception, check its position in the list before testing anything else.

The procedure: back up, inventory, rules, test

The deployment sequence in the sourced material starts before any rule exists, and its order is the safety mechanism:

  1. Export the existing router configuration. Save the backup somewhere off the firewall itself. This file is the way back from every later step.
  2. Write the service inventory (table above): one row per service, with source segments, port, and direction.
  3. Build the management network and restrict firewall administration to it, so the web UI is reachable from one segment only, and confirm that access works before moving on.
  4. Create the separate networks the layout needs. LAN, guest, and IoT are the documented starting set, each with its address range and DHCP running on the provider the installed version actually uses.
  5. Add the baseline to one segment first: allow DNS to the gateway, block RFC1918 destinations, allow the internet, in that order.
  6. Add that segment's exceptions above the block, one per inventory row, each limited to a single port.
  7. Start outbound rules with logging on, so the first days of traffic show which flows the inventory missed, as log entries instead of as silent breakage.
  8. Test after each rule change using the checks in the next section, then repeat steps 5 to 7 for the next segment.
  9. Save a fresh configuration backup and test a restore of it. A backup that has never been restored is a hope, not a recovery plan.

What success looks like

Four checks, run from real devices on the segment just configured, confirm the ruleset does what the inventory says:

  1. Names resolve and the internet loads from the test device, the DNS allow and the internet allow both work.
  2. A private destination with no exception refuses or times out, for example, a server on another VLAN with no inventory row. The block is real, not assumed.
  3. Each named exception works exactly as scoped: the service answers on its one port, from the one segment allowed to reach it, and fails from a segment the inventory did not list.
  4. The firewall web UI opens from the management path and from nowhere else tested, administration is restricted as designed.

Record the result of each check next to its inventory row. A check that fails names the rule to inspect; a check that was never run names a risk still hiding in the ruleset.

Five breakages, and the fix for each

A service stopped working after the rules went in. First suspect is position: its allow rule sits below the block-RFC1918 rule and is never reached. Move it above the block and retest. Nothing on the new segment can resolve names. The DNS allow to the gateway is missing or below the block; DNS failure looks like total failure, because every lookup dies before any other rule matters. The web UI is unreachable. Administration was restricted before the management path was proven; return via the configuration backup from step 1, then restrict administration only after the management network tests clean.

DHCP steps do not match the screens. A version difference, most likely the OPNsense 26.1 provider change; follow the provider the install runs. IoT devices can still reach the servers. The internet allow sits above the RFC1918 block, so private traffic matches the allow first; restore the documented order.

The decision: how much segmentation is enough

Segmentation earns its upkeep per boundary, not per VLAN count. A lab with IoT devices that have no reason to touch the NAS gains real protection from the baseline on that one segment, even with everything else flat. A lab where trusted computers, servers, and management already sit apart gains more from auditing its exceptions, each one narrow, each one still needed, than from adding segments.

The flat-network starting point still uses the same inventory: the list of what must talk to what is the ruleset's source of truth on any layout, and it is the document that makes the next change safe. Start from the inventory, keep the baseline order, test after every rule, and keep the backup current, that sequence, repeated, is the skill the template was never going to teach.

, Dex Carter, Tech Writer