Skip to content
subuilds.dev

← logbuild #19 passed790ed6a

OPNsense Core Features Setup: Blocking, DNS Resolution & Hardening

Block websites and categories, show LAN hostnames in firewall logs, and harden OPNsense itself. These are practical steps for every homelab admin after the first install.

· 13 min read

You installed OPNsense. The WAN is up, traffic passes, and you feel good. Then you see three problems. The firewall logs show only raw IPs. Your kids open gambling sites from the family VLAN. The admin panel still answers on port 443 from anywhere. It is time to fix all three.

This post covers four tasks to do right after a fresh OPNsense install:

  1. Block a specific website with aliases and firewall rules
  2. Resolve LAN IP addresses to hostnames in firewall logs
  3. Block whole categories with DNS (gambling, malware, torrents)
  4. Harden OPNsense itself against wrong settings and unwanted access

Environment: OPNsense 26.1.2, Unbound DNS Resolver, single LAN subnet 10.10.1.0/24.


In Simple Words#

The problem
After a fresh OPNsense install, the firewall logs show only raw IP addresses. Unwanted sites, such as gambling sites, still open. The admin panel answers from anywhere.
The root cause
These are the default settings. A new install has no block rules, no names for your LAN hosts, and loose admin settings. You must add them yourself.
The solution
Block single sites with a firewall alias and a rule. Give LAN hosts names with Unbound host overrides. Block whole categories with DNS block lists. Then harden OPNsense itself.
Think of it like this
A new guard stands at your door. He lets everyone in and writes only house numbers in his notebook. You give him a list of people who may not enter, a name for each house number, and a lock for his own room.

1. Block a Specific Website#

There are two ways. Use Option 1 (Firewall Alias) to block specific sites. It works and is the most direct way. Use Option 2 (DNS override) as an extra layer, or when you want a simple block without a firewall rule.

Step 1 — Create the Alias#

An alias is a named list that you can use in firewall rules. Here it is a list of domains. Go to Firewall → Aliases and click +:

Field Value
Name BLOCK_REDDIT
Type Host(s)
Description Block Reddit on LAN

In the Content field, add all domains that the site needs. The main domain alone is not enough for sites that load their files from a CDN:

text
reddit.com
www.reddit.com
old.reddit.com
redd.it
redditstatic.com
redditmedia.com

Click Save → Apply changes.

Step 2 — Create the Block Rule#

Go to Firewall → Rules → LAN and click +:

Field Value
Action Block
Interface LAN
Direction in
TCP/IP Version IPv4+IPv6
Protocol any
Source LAN net
Destination BLOCK_REDDIT (alias)
Description Block Reddit from LAN

Move this rule above your default allow rules. OPNsense reads the rules from top to bottom and stops at the first match.

Click Save → Apply changes.


2. Resolve LAN IPs to Hostnames in Firewall Logs#

By default, OPNsense firewall logs show raw IPs like 10.10.1.21. You want them to show gitlab or gitlab.home.lab. Names are much faster to read when you look for a problem at 2 AM.

The solution is Unbound Host Overrides. Unbound is the DNS server inside OPNsense. A host override is a static DNS entry that gives a LAN IP a name you can read. After you set them, the firewall log shows the names automatically.

Step 1 — Add Host Overrides in Unbound#

Go to Services → Unbound DNS → Overrides → Host Overrides and click + for each LAN host:

Host Domain Type IP Description
gitlab home.lab A 10.10.1.21 GitLab server
proxmox home.lab A 10.10.1.10 Proxmox hypervisor
grafana home.lab A 10.10.1.30 Grafana monitoring
nas home.lab A 10.10.1.50 NAS storage

Click Save after each entry. When all are added, click Apply.

Step 2 — Enable Reverse DNS in Unbound#

To let OPNsense resolve 10.10.1.21 → gitlab.home.lab, you also need PTR records. A PTR record is the reverse of a normal DNS entry: it maps an IP to a name. Unbound can create these automatically.

Go to Services → Unbound DNS → General:

  • Enable Register DHCP leases: this adds PTR records for DHCP clients
  • Enable Register DHCP static mappings: this adds PTR records for static DHCP entries

Click Save → Apply.

Step 3 — Verify Resolution#

From any LAN host, check that the name resolves:

bash
nslookup gitlab.home.lab 10.10.1.1
# Expected: 10.10.1.21

nslookup 10.10.1.21 10.10.1.1
# Expected: gitlab.home.lab (reverse lookup)

3. Category-Based DNS Blocking with DNSBL#

Blocking sites one by one by hand is too much work when there are many. For gambling, malware, tracking, and torrent sites, you want blocking from feeds. A feed is a list with thousands of domains that updates automatically. OPNsense has a built-in DNSBL (DNS Block List) feature in Unbound.

How It Works#

  1. A LAN client asks for gambling-site.com. The question goes to Unbound, the DNS server on OPNsense.
  2. Unbound looks in its block list. OPNsense downloads this list from feeds with thousands of domains. The domain is on the list.
  3. Unbound answers NXDOMAIN, which means “domain not found”. The client cannot open the site.
  4. google.com is not on the list. Unbound asks a DNS server on the internet, as normal.
  5. The answer comes back, and the client gets the IP address. Only domains on the list are blocked.
5 / 5

Step 1 — Enable DNSBL in Unbound#

Go to Services → Unbound DNS → Blocklist:

  • Check Enable
  • Set Type to Unbound (native mode, no extra packages)

Step 2 — Add Block List Feeds#

In the same Blocklist tab, scroll to URLs and add the feeds you want. These lists are free and kept up to date:

Category Feed URL
Ads & Tracking https://adaway.org/hosts.txt
Malware https://malware-filter.pages.dev/malware-filter-hosts.txt
Gambling https://raw.githubusercontent.com/nickspaargaren/no-google/master/categories/gambling.txt
Torrent sites https://raw.githubusercontent.com/nickspaargaren/pihole-google/master/categories/torrent.txt
Adult content https://raw.githubusercontent.com/nickspaargaren/no-google/master/categories/porn.txt

Add each URL, then click Save → Apply.

Step 3 — Configure the Sinkhole Response#

The block action is the answer a client gets for a blocked domain. In the Blocklist settings, set Block action to one of:

  • Return NXDOMAIN: the simplest. The client sees “domain not found”
  • Return NODATA: like NXDOMAIN. Some clients handle it better
  • Redirect to sinkhole: returns 0.0.0.0 or the IP of your own block page

Return NXDOMAIN works for most homelabs.

Step 4 — Force Update the Lists#

After you save, click Force Update to download the feeds right away. From then on, OPNsense refreshes them automatically on a schedule.

Verify Blocking Works#

bash
nslookup gambling-site.com 10.10.1.1
# Expected: NXDOMAIN or 0.0.0.0

nslookup google.com 10.10.1.1
# Expected: resolves normally

Allowlisting Exceptions#

If a blocklist blocks a good domain by mistake:

Go to Services → Unbound DNS → Blocklist → Allowlist → click +:

Field Value
Domain legitimate-site.com
Type Domain

This allows the domain permanently, no matter which list blocks it.


4. Hardening OPNsense Itself#

The firewall protects your network. But who protects the firewall? These are the steps I run on every fresh OPNsense install before it handles real traffic.

4.1 Restrict Admin Interface Access#

By default, the web GUI listens on all interfaces. Limit it to LAN only and move it away from port 443.

Go to System → Settings → Administration:

Setting Recommended Value
Protocol HTTPS
SSL Certificate Your own cert or self-signed
TCP port 8443 (or any non-standard port)
Listen Interfaces LAN only (uncheck WAN)
HTTP Redirect Enable (redirect 80 → HTTPS)
Anti-lockout rule Keep enabled during setup

Click Save.

4.2 Harden SSH Access#

If you use SSH for remote access or automation:

Go to System → Settings → Administration → Secure Shell:

  • Enable SSH only if you really use it
  • Set Login Group to admins only
  • Set SSH Authentication Method to Public Key Only
  • Change the port from 22 to a less common port (for example 2222)

Add your public key under System → Access → Users → your user → Authorized keys.

bash
ssh -p 2222 -i ~/.ssh/id_ed25519 [email protected]

When you have checked that the key login works, disable password authentication completely.

4.3 Enable Automatic Updates#

Go to System → Firmware → Settings:

  • Set Release type to Production
  • Enable Automatic updates
  • Set the schedule to weekly (for example Sunday 03:00)

OPNsense downloads the updates and prepares them for install. For critical security patches, enable Auto-reboot after update, at a time outside your busy hours.

4.4 Disable Unused Services#

Every enabled service is an attack surface: one more place where an attacker can try to get in. Disable what you do not use.

Go to System → Settings → Administration:

Service Disable if…
SSH You manage OPNsense only via GUI
Console menu Physical access is not a concern
mDNS repeater You do not need Bonjour/Avahi across VLANs

Go to VPN and disable any VPN services (OpenVPN, WireGuard, IPsec) that you do not use.

Go to Services, then stop and disable the services your setup does not need (for example Dyndns, Proxy, Stunnel).

4.5 Enable Intrusion Detection (Suricata)#

Do you open any service to the internet, such as a VPN or a port forward to a home server? Then Suricata adds an important layer of protection. Suricata is an IDS (intrusion detection system): it watches traffic for attacks.

Go to Services → Intrusion Detection → Administration:

  • Enable IDS on WAN interface
  • Download Emerging Threats Open rulesets
  • Start in IDS mode (alerts only). Move to IPS mode after you have watched the traffic for a week

4.6 Check the Firewall Ruleset for Loose Rules#

Go to Firewall → Rules and look at each interface.

Common mistakes after the first setup:

  • Any-to-any allow rule on LAN: left over from the default install. Replace it with one clear rule for each allowed destination
  • WAN rules that allow inbound on wide port ranges: each open port should have a written reason
  • No outbound rules: add source-based rules, so IoT devices can reach only the internet and not your LAN servers

4.7 Verify the Backup Configuration#

Go to System → Configuration → Backups → Download configuration.

Store the config XML in a safe place (a password manager, an encrypted USB drive, or your NAS). After any big change, download it again.


End State: What You Now Have#

After you finish this guide, your OPNsense install does the following:

  1. At the start, OPNsense sits between the internet and your LAN (10.10.1.0/24). Traffic passes, but nothing is blocked yet.
  2. Part 1: Firewall Alias rules block chosen sites by IP.
  3. Part 2: Unbound host overrides turn LAN IPs into hostnames in the firewall logs.
  4. Part 3: Unbound DNSBL blocks whole categories, such as gambling, malware and torrents.
  5. Part 4: the admin page is only open on the LAN, SSH needs keys, and updates run on their own.
  6. Part 4.5: Suricata watches the WAN traffic with the Emerging Threats rules.
6 / 6
  • Specific sites blocked with Firewall Alias rules (with all CDN and asset domains)
  • Optional block at the DNS layer with Unbound host overrides, for more coverage
  • LAN hosts show as hostnames in firewall logs
  • Category blocklists (gambling, malware, torrents) applied with DNSBL
  • Admin interface limited to LAN, on a non-standard port
  • SSH with keys only, password login disabled
  • Automatic firmware updates scheduled
  • Suricata watching WAN traffic

What to Do Next#

If you have not set up monitoring yet, the Grafana + Prometheus homelab stack works well with OPNsense. You can export firewall and Suricata metrics and build dashboards. They show blocked domains, the hosts with the most traffic, and alert trends over time.

For more detail on IDS (rule tuning, IPS mode, and safe attack simulation), continue to the OPNsense Intrusion Detection Guide.

Do you have a question, or another blocklist that you trust? Write it in the comments.