How to Change DNS on OPNsense (Firewall-Wide)
Set a faster DNS resolver in OPNsense under System, Settings, General, then have Unbound forward every device's lookup to it — with optional DNS-over-TLS.
-
Sign in to the OPNsense web interface
Open a browser to your firewall's LAN address (https://192.168.1.1 by default, or whatever IP you assigned) and log in with your admin account. All DNS changes are made from this web GUI, not the console.
-
Open System, Settings, General
In the left menu go to System → Settings → General. This page contains the "DNS servers" section that controls what upstream resolvers the firewall itself uses.
-
Enter your DNS servers
Under "DNS servers", type 1.1.1.1 in the first field, then use the "+" (add) control to add a second row and enter 1.0.0.1 (or the two addresses that won your speed test). Leave the per-row "Gateway" dropdown on its default/none unless you run multi-WAN and want to pin each resolver to a specific gateway.
-
Stop your ISP from overriding DNS
Uncheck "Allow DNS server list to be overridden by DHCP/PPP on WAN" so your ISP's DHCP-supplied servers can't replace the ones you just entered. Leave "Do not use the local DNS service as a nameserver for this system" unchecked if you want the firewall to keep using its own Unbound resolver; check it only if you want the firewall to query the upstream servers directly.
-
Save the general settings
Click Save at the bottom of the page. This sets the resolvers the firewall uses for its own lookups (updates, plugins, etc.). On its own it does not yet change what your LAN clients use — that is the next step.
-
Point Unbound at those servers for the whole network
Go to Services → Unbound DNS → Query Forwarding. Add an entry with the Domain field left blank, Server IP 1.1.1.1, Port 53, and add a second entry for 1.0.0.1. Save, then Apply. Because Unbound resolves recursively by default, adding these forward entries is what actually routes every client's lookups through your chosen resolver.
-
Verify from a device on the network
From any LAN device, run nslookup example.com (or dig) — it should answer through the firewall — then reload this site and run the DNS speed test to confirm the resolver you picked is the one in use.
Why change DNS on OPNsense
OPNsense sits between your whole network and the internet, so changing its DNS is the single most efficient place to apply a faster resolver: every phone, laptop, TV, and IoT device behind the firewall benefits at once, with no per-device setup. By default OPNsense runs the Unbound resolver on the LAN and hands out the firewall’s own address as the DNS server via DHCP, so clients already point at the firewall — you’re just changing where the firewall sends those lookups.
A faster resolver shortens the lookup delay before a page starts to load. It does not increase your bandwidth, throughput, or download speed — those are set by your ISP plan and line. What you’re trimming is the round-trip time spent turning a hostname into an IP address, which happens before any real data transfer begins.
Before you start, run the DNS speed test from a device on this network, pick the resolver that responds fastest from your connection, and use its two addresses in place of the Cloudflare examples below. You can also compare resolvers on the public DNS servers page if privacy or filtering matters to you as well as speed.
The key OPNsense detail: recursive vs. forwarding
This trips up a lot of people, so it’s worth stating plainly. Out of the box, Unbound is a recursive resolver — it talks directly to the authoritative name servers on the internet and does not forward to whatever you type into System → Settings → General. That means entering 1.1.1.1 there alone changes only the firewall’s own name resolution, not what your LAN clients ultimately use.
To make the whole network actually use Cloudflare (or any specific resolver), you switch Unbound into forwarding mode by adding Query Forwarding entries, as in step 6. If you’d rather keep Unbound resolving recursively — a perfectly valid, privacy-friendly choice that talks to no single third party — then skip step 6 and understand that the addresses in System → Settings → General are just the firewall’s fallback, not your network’s resolver.
OPNsense vs. pfSense and version differences
- This guide is OPNsense-specific. pfSense uses different menu paths (System → General Setup for the servers, and Services → DNS Resolver for Unbound). Don’t apply these exact labels there.
- Tab locations shift between OPNsense releases. The Unbound sub-tabs (Query Forwarding, DNS over TLS) have moved and been renamed across major versions. If a tab isn’t where described, look through the full Services → Unbound DNS menu — the option exists, it may just sit under a slightly different tab name on your build.
- Dnsmasq option. Some installs use Dnsmasq DNS instead of Unbound. If your resolver service is Dnsmasq (Services → Dnsmasq DNS), the forwarding is configured there instead; the System → Settings → General part is identical.
Encrypted DNS (DoT/DoH)
OPNsense does support encrypted DNS natively — specifically DNS over TLS (DoT) through Unbound, so every device on your network gets encrypted lookups without any per-device configuration.
- Go to Services → Unbound DNS → DNS over TLS.
- Add a server: Server IP
1.1.1.1, Port853, Verify CNcloudflare-dns.com. - Add a second entry for
1.0.0.1with the same port and Verify CN. - Save, then Apply. Adding servers on this tab puts Unbound into forwarding-over-TLS mode, so all queries leave the firewall encrypted to Cloudflare on port 853.
The “Verify CN” value is the hostname Unbound checks the resolver’s TLS certificate against — this is the part that makes the connection genuinely secure rather than just encrypted. In raw Unbound terms this maps to 1.1.1.1@853#cloudflare-dns.com; the GUI just splits the IP, the @853 port, and the #-hostname into three fields. If you used the DNS over TLS tab, you don’t also need the plain Query Forwarding entries from step 6 — pick one path.
A note on DoH: Unbound’s GUI does not forward upstream over DNS-over-HTTPS. If you specifically need DoH out of the firewall, that requires the optional os-dnscrypt-proxy plugin rather than a built-in menu — so don’t expect a native “DoH” checkbox. For picking an encrypted resolver and getting its exact DoT hostname or DoH endpoint, use our encrypted DNS setup generator.
Verify it worked
- Confirm resolution works. From a LAN device, run
nslookup example.com(Windows) ordig example.com(macOS/Linux). It should resolve through the firewall’s LAN IP — that’s expected, since clients query Unbound, not Cloudflare directly. - Confirm the upstream resolver. Because clients see the firewall as their DNS, don’t judge by the DNS IP shown on the client. Instead, from a device on the network open
https://one.one.one.one/help— with Cloudflare configured it reports Connected to 1.1.1.1: Yes, and if you set up DoT it shows DNS over TLS: Yes. - Watch it live on the firewall. Services → Unbound DNS → Log File shows queries as they happen, and Reporting → Unbound DNS confirms Unbound is answering with per-query statistics.
- Re-run the speed test. Reload this site and run the DNS speed test from a couple of devices; your chosen resolver should show up as the one in use, and ideally the fastest.
Troubleshooting
- Clients still resolve after saving System → Settings → General only. Expected — that page sets the firewall’s own resolvers, not the network’s. Add the Query Forwarding entries (step 6) or a DNS over TLS server to route client lookups.
- DoT set up but resolution stops working. Double-check the Verify CN matches the resolver’s certificate hostname exactly (
cloudflare-dns.comfor Cloudflare) and that port is853. A wrong CN or a firewall rule blocking outbound 853 will make every lookup fail. - ISP DNS keeps coming back. Confirm “Allow DNS server list to be overridden by DHCP/PPP on WAN” is unchecked under System → Settings → General.
- Some sites won’t load. If you enabled forwarding, DNSSEC handling can interact with a misbehaving upstream — try the other resolver from the public DNS servers page, or temporarily revert to recursive mode to isolate whether DNS is really the cause.
- A single device ignores the firewall’s DNS. That device likely has its own hardcoded DNS (common on some smart TVs and phones using private DNS). It overrides anything the firewall hands out; change or clear it on the device itself.
Revert to your old settings
To undo the change: remove the entries you added under Services → Unbound DNS → Query Forwarding (and any under DNS over TLS), then Save and Apply — this returns Unbound to recursive resolution. Under System → Settings → General, clear the DNS server addresses you entered (or re-check “Allow DNS server list to be overridden by DHCP/PPP on WAN”) and Save to hand control back to your ISP’s DHCP-supplied servers. Clients pick up the change on their next DNS query or DHCP renewal.