To set up a firewall in a homelab, put a dedicated firewall box with two network ports between your ISP modem and your switches, install OPNsense or pfSense, and give it a WAN interface from your ISP and a LAN interface for your home network. Then segment lab, IoT and guest networks, block inbound traffic by default, and expose public services only through a reverse proxy.
Key takeaways
- A homelab firewall needs a box with at least two network ports, placed between the ISP modem and your switches.
- Segment into LAN, lab, IoT and guest networks, and block lab and IoT traffic from reaching your home LAN.
- Default-deny inbound traffic, expose services only through a reverse proxy, and log blocked traffic while you learn.
A homelab is where you learn by breaking things — and that is exactly why it needs a firewall. Without one, a vulnerable test server, an exposed service or a compromised IoT gadget shares a flat network with your laptop, your files and your family.
What is a homelab firewall?
A homelab firewall is a dedicated router and firewall that sits between your internet connection and your home networks, controlling which traffic can pass in each direction. It is the boundary that keeps lab experiments, public services and untrusted devices away from your everyday devices.
Most home routers combine modem, router, switch and Wi-Fi in one box with limited controls. A dedicated firewall gives you separate networks, per-network rules, logging, intrusion detection and VPN access — the same concepts used in small business networks, at home scale. Segmenting devices and keeping firmware updated are the basic habits that make that boundary work.
How should I plan my homelab network?
Plan the networks before you buy hardware. Most homelabs need at least three: a LAN for trusted home devices, a lab network for servers and virtual machines, and an IoT or guest network for untrusted things. Each gets its own subnet, such as 192.168.10.0/24 for LAN and 192.168.20.0/24 for the lab.
The lab network is the key idea. Lab servers need internet access for updates, but they should not be able to reach your home LAN. If a lab service is compromised, the attacker finds a dead end instead of your laptop and your file shares. Keep the plan simple at first: LAN, lab and one extra network for IoT or guests, and add more only when you need them.
What hardware do I need?
You need a machine with at least two network interface cards (NICs): one for WAN and one for LAN. A used mini PC, an old desktop with a second network card, or a purpose-built firewall appliance all work. For a gigabit connection with a few VLANs, choose a modern low-power CPU with headroom for VPN and intrusion-detection work, and check the firewall project's hardware sizing guidance before you buy.
Other essentials are a USB stick for the installer, a monitor and keyboard for the first boot, and a managed switch if you want VLANs. A managed switch lets several networks share one cable from the firewall by tagging traffic, which is how most homelabs run four networks on a two-port box. Avoid USB network adapters for the WAN port where you can: they are less reliable than built-in or PCIe ports.
OPNsense vs pfSense: which should I pick?
OPNsense and pfSense are the two dominant free firewall platforms for homelabs, and both are based on FreeBSD. OPNsense is a fork of pfSense with a more modern interface, a faster release cycle and WireGuard built in. pfSense has a longer history, a huge user base and extensive documentation and forum guides.
For most beginners either works. OPNsense is often the easier first experience because of its interface, while pfSense is the safer choice if you want to follow a specific older guide word for word. The honest test is to run both in a virtual machine for an evening and pick the one whose menus make sense to you.
| OPNsense | pfSense | Linux with nftables | |
|---|---|---|---|
| Cost | Free, open source | Free, open source | Free, open source |
| Interface | Modern web UI | Classic web UI | Command line |
| WireGuard | Built in | Available as a package | Built into the kernel |
| Best for | Beginners who want a clean UI | Users following established guides | Users who want full control |
| Learning curve | Low | Low to medium | High |
Whichever you pick, download it only from the official site — OPNsense documentation or the pfSense documentation — and verify the download if the project offers checksums.
How do I install and do the first setup?
Installation follows the same shape on both platforms. Download the installer image for your hardware, flash it to a USB stick with a tool such as Rufus or balenaEtcher, and boot the firewall box from it. The installer asks which port is WAN and which is LAN, then installs to the internal drive.
- Flash the installer to a USB stick of at least 4 GB.
- Boot the firewall box from USB, with a monitor and keyboard attached, and run the installer.
- Assign interfaces: WAN gets an address from your ISP by DHCP; LAN gets a static address such as 192.168.10.1/24.
- Put the ISP router in bridge or modem mode so your firewall receives the public address and you avoid double NAT.
- Connect a laptop to the LAN port and open the web interface, usually at the LAN address on HTTPS.
- Run the setup wizard: set the admin password, time zone, DNS servers and a hostname.
- Change the default password immediately and, if offered, disable the default admin account's weak defaults.
Do the first setup with only the firewall and one laptop connected. Once the LAN works and the laptop reaches the internet through the firewall, move the rest of your network behind it.
What firewall rules should I start with?
Start with default deny on the WAN side and a small set of explicit allows inside. Rules are checked top to bottom, so order matters: specific allows first, broad blocks last, and a final deny with logging at the bottom of each interface.
- WAN: block everything inbound by default. Allow only established and related traffic back in, plus any port forwards you deliberately create.
- LAN: allow LAN devices to reach the internet and, where needed, specific lab services. Restrict admin access to the firewall web interface to the LAN only.
- Lab: allow lab devices to reach the internet for updates, and to the firewall for DNS and NTP. Block lab traffic to the LAN.
- IoT and guest: allow internet only. Block access to the LAN, the lab and the firewall's admin interface.
Log your block rules at first. The logs show you what you broke — usually a DNS or NTP rule you forgot — before your family notices the internet is down.
How do I handle DNS, VPN and remote access?
Use the firewall as your DNS resolver so you control names inside the lab. Enable the resolver, point DHCP clients at the firewall address, and add host overrides such as nas.lab.local for your servers. This also lets you block ads and tracking at the network level with a tool such as Pi-hole if you want it later.
For remote access, run a VPN on the firewall — WireGuard is the usual homelab choice — and never open the firewall's web interface or SSH to the internet. A VPN gives you one authenticated, encrypted door into the lab, and you can close every other inbound port. Check your public address and DNS from outside with our what-is-my-ip tool after you set the VPN up.
How do I safely expose a service to the internet?
Expose as little as possible, and use a reverse proxy. Run Caddy, Traefik or Nginx in the lab, forward only ports 80 and 443 from the WAN to that proxy, and let the proxy route requests to individual services by hostname. That way a new service never needs a new open port.
Before you expose anything, check three things: the service is updated, it has strong authentication (ideally with a second factor), and you have a plan for watching its logs. Services without authentication, such as an open dashboard or an unprotected file share, should never face the internet. For the wider home network, our guide to how to secure your Wi-Fi covers the wireless side.
What mistakes do beginners make?
The most common mistakes are all avoidable. Opening too many ports, leaving the ISP router doing NAT as well as the firewall, putting lab servers on the same network as home devices, and forgetting to back up the firewall configuration before an upgrade all cause real outages.
- Double NAT: forgetting bridge mode on the ISP router breaks port forwarding and some games and calls.
- Flat network: one network for everything means one compromised device can reach everything.
- Allow-all rules: a rule that allows a whole network to anywhere defeats the point of segmentation.
- No backups: export the firewall configuration after every change and store a copy off the box.
- No updates: the firewall is the most exposed device you own; update it promptly.
How do I maintain a homelab firewall?
Maintenance is mostly routine. Update the firewall software and its packages on a schedule, review the blocked-traffic logs weekly at first, prune rules you no longer need, and test your backups by restoring one in a virtual machine. Add intrusion detection (Suricata or Snort) only after the basics are stable — it generates noise that is hard to interpret on a shaky setup.
Also document your own network: a one-page note listing each subnet, what lives on it and which ports are open saves hours when something breaks at midnight. Keep that note somewhere you can reach it when the network is down — not only on a server inside the network.
The bottom line
A homelab firewall is a weekend project with lasting value: two network ports, a free firewall platform, three or four segments, and a short list of deliberate rules. Start with default deny, segment the lab away from your home devices, and expose services only through a reverse proxy.
Once the basics work, add a VPN and logging, then iterate. You can check the security headers of any service you expose with our free security headers checker.
Frequently asked questions
What is a homelab firewall?
A homelab firewall is a dedicated router and firewall that protects a home lab — the servers, virtual machines and test services you run at home. It separates the lab from your everyday home devices so experiments and exposed services cannot put your laptops, phones and files at risk.
Do I need a separate firewall box for a homelab?
You do not strictly need one, but a separate box with two network ports is the recommended setup. It keeps firewall duties off your servers, survives reboots of lab machines, and gives you a clean boundary between the internet and your networks.
Should I choose OPNsense or pfSense for a homelab?
Both are free, open-source firewall platforms based on FreeBSD. OPNsense has a more modern interface and built-in WireGuard support, while pfSense has a longer history and a very large library of guides. Try both in a virtual machine and pick the interface you prefer.
How many network ports does a homelab firewall need?
At least two: one WAN port for the internet and one LAN port for your internal network. More ports, or VLANs on a managed switch, let you run separate lab, IoT and guest networks without extra cables.
Is it safe to expose homelab services to the internet?
Only with care. Expose as little as possible, use a reverse proxy so only ports 80 and 443 are open, keep everything updated, use strong authentication, and prefer a VPN such as WireGuard for admin access instead of opening management ports.
What is double NAT and should I avoid it?
Double NAT happens when your ISP router and your firewall both translate addresses, which can break port forwarding and some services. Put the ISP modem or router in bridge or modem mode so your firewall gets the public address directly.
How much does a homelab firewall cost?
A used mini PC or old computer with two network ports can cost very little, while a new purpose-built box such as a Protectli-style appliance typically costs a few hundred dollars. OPNsense and pfSense themselves are free to download and use.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against OPNsense and pfSense official documentation and WireGuard installation documentation.
How we write and fact-check →