Why does encrypted DNS bypass the router?
Classic DNS travels in the clear on port 53: the router sees it, can redirect it to itself, filter it, log it. It’s what we do in the howto on transparent DNS with the bridge NAT, and it works well with PCs, cameras and smart TVs.
Encrypted DNS doesn’t. There are two ways to do it, and both go right under the router’s nose:
- DNS over TLS (DoT): the requests travel encrypted on a dedicated port, 853. It’s what Android uses with the “private DNS” option;
- DNS over HTTPS (DoH): the requests travel inside a normal HTTPS connection, on port 443, the same as every website. It’s what browsers use: Firefox, Chrome, Edge.
DoT is blocked with one rule. DoH isn’t: you can’t close port 443 without closing the internet. You fight it by recognizing who the connection is going to. In the lab I tried four techniques, one after the other, from a Linux PC behind the MikroTik: in the end DoT and DoH toward Cloudflare, Google and 1.1.1.1 were blocked, and normal browsing worked.

Step 1: how do I block DNS over TLS?
It’s a port: you close it in forward, for all the traffic that crosses the router.
/ip firewall filter
add chain=forward protocol=tcp dst-port=853 action=reject reject-with=tcp-reset \
comment="Block DNS over TLS" place-before=[find action=fasttrack-connection]
add chain=forward protocol=udp dst-port=853 action=drop \
comment="Block DNS over QUIC" place-before=[find action=fasttrack-connection]
place-before=[find action=fasttrack-connection] puts the rule right before the fasttrack, high up in the chain. Don’t use destination=0 or place-before=0: on the default firewall rule 0 is the dynamic one for the fasttrack counters, and RouterOS answers cannot move builtin.
The UDP rule covers DNS over QUIC, the DoT’s younger sibling, which uses the same port. The reject with tcp-reset makes the device understand right away that the road is closed, instead of leaving it waiting: an Android phone with private DNS on automatic goes back to normal DNS.
In the lab, before: kdig +tls @1.1.1.1 mikrotik.com answered. After: no answer, neither from 1.1.1.1 nor from 8.8.8.8.
Step 2: how do I recognize the DoH servers?
The DoH servers are few and famous: Google, Cloudflare, Quad9, OpenDNS, AdGuard. RouterOS lets you put a name in an address list instead of an address: the router resolves it by itself and keeps the addresses up to date.
/ip firewall address-list
add list=server-doh address=dns.google
add list=server-doh address=one.one.one.one
add list=server-doh address=cloudflare-dns.com
add list=server-doh address=mozilla.cloudflare-dns.com
add list=server-doh address=dns.quad9.net
add list=server-doh address=doh.opendns.com
add list=server-doh address=dns.adguard-dns.com
Look at the result:
/ip firewall address-list print where list=server-doh
Under each name the dynamic entries (D flag) show up with its addresses: dns.google brings along 8.8.8.8 and 8.8.4.4, one.one.one.one brings 1.1.1.1 and 1.0.0.1, dns.quad9.net brings 9.9.9.9. That’s why you shouldn’t also add the addresses by hand: in the lab, with 8.8.8.8 written together with dns.google, the router answered already have such entry. The names in the lists are explained in the MikroTik manual: Address-lists.
Step 3: how do I block DoH toward those servers?
Close port 443, TCP and UDP (HTTP/3 travels over UDP), only toward the list:
/ip firewall filter
add chain=forward protocol=tcp dst-port=443 dst-address-list=server-doh \
action=reject reject-with=tcp-reset comment="Block DoH to the known servers" \
place-before=[find action=fasttrack-connection]
add chain=forward protocol=udp dst-port=443 dst-address-list=server-doh \
action=drop comment="Block DoH over HTTP/3" place-before=[find action=fasttrack-connection]
In the lab, from the PC behind the router, before these rules the DoH requests to cloudflare-dns.com, to dns.google and directly to https://1.1.1.1/dns-query all answered; after, none. And https://mikrotik.com kept opening.
⚠️ Warning: 8.8.8.8, 1.1.1.1 and 9.9.9.9 stay reachable on port 53. You only block their encrypted DNS; normal DNS toward them keeps working, unless you redirect it to the router as in the transparent DNS.
Step 4: and the name inside the TLS connection?
When a browser opens an HTTPS connection, in the first packet it writes in the clear the name of the site it wants (the SNI). The firewall’s tls-host matcher reads it, and it’s useful for the DoH servers that change address often because they sit behind a CDN:
/ip firewall filter
add chain=forward protocol=tcp dst-port=443 tls-host=*dns.google \
action=reject reject-with=tcp-reset comment="Block DoH by name" \
place-before=[find action=fasttrack-connection]
Two things I saw in the lab, and one the manual says:
- the rule has to go before the fasttrack and before the
accept established, and that’s the reason for theplace-before. The first TLS packet arrives when the connection is already “established”: at the bottom of the chain the default rule accepts it first, and yours never sees it. Put at the bottom, the DoH went through; put before the fasttrack, blocked. If your firewall has no fasttrack, theplace-beforefinds nothing and the rule ends up at the bottom: move it yourself above theaccept established; - without a name it doesn’t work:
https://1.1.1.1/dns-queryhas no name inside, and withtls-hostalone it went through. That’s why you also need the list from step 2; - the manual warns that the matcher doesn’t see the name if the first TLS packet is split into several segments, which happens with recent browsers. The
tls-hostis a reinforcement, not the main defense.
All the matchers are in the MikroTik manual: Filter.
Step 5: how do I turn off Firefox’s DoH without touching the PCs?
Firefox, before turning on DoH by itself, asks the network’s DNS for the name use-application-dns.net. If the answer is “it doesn’t exist”, it understands that the network wants to manage DNS and leaves DoH off. One static entry is enough:
/ip dns static add name=use-application-dns.net type=NXDOMAIN
In the lab, asked of the router, use-application-dns.net answers “not found”; asked directly of 9.9.9.9, it answers normally. So it only works if the PCs use the router’s DNS: the default DHCP gives it to them, and for the devices that have a DNS written inside there’s the transparent DNS with the bridge NAT. Static entries are in the MikroTik manual: DNS.
It only applies to automatic activation: if the user turned DoH on by hand, Firefox uses it anyway, and there the rules from steps 3 and 4 come in.
Step 6: how do I check everything’s closed?
From a Linux PC behind the router:
kdig +tls @1.1.1.1 mikrotik.com
curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=mikrotik.com&type=A'
curl 'https://dns.google/resolve?name=mikrotik.com&type=A'
curl -I https://mikrotik.com/
The first three must fail, the last must answer. On the router the counters tell you what’s working:
/ip firewall filter print stats where comment~"Block"
What do I check before putting it in production?
- it’s not a perfect wall: whoever uses a DoH server that isn’t on the list, or a VPN, gets through. For company devices the definitive solution is to turn off DoH with the browser policies (Firefox, Chrome and Edge have them) and private DNS on the managed phones; the router covers everything else;
- keep the list curated: if a service stops working, look at the counters from step 6 before looking elsewhere;
- the rules are in forward and don’t touch the router itself, which keeps using its own DNS, even over DoH if you configured it that way;
- the router that decides the DNS for the whole network has to be protected: follow the Basic hardening of a MikroTik router.
How it works under the hood, in the Dojo Knowledge Base: address lists, including with DNS names, rule order and the fasttrack dummy rule.
Tested in the lab on PNETLab with a CHR running RouterOS 7.24.5 (stable) and a Debian 12 client behind the router, with the default firewall and fasttrack on: DoT toward 1.1.1.1 and 8.8.8.8 blocked, address list with the DoH servers’ names (and the error when adding the addresses too), DoH toward cloudflare-dns.com, dns.google and 1.1.1.1 blocked with normal browsing working, tls-host effective only at the top of the chain and useless without a name, use-application-dns.net in NXDOMAIN from the router’s DNS. Firefox’s behavior with the canary domain comes from Mozilla’s documentation.
Frequently asked questions
How do I block DNS over HTTPS with MikroTik?
With an address list containing the names of the DoH servers (dns.google, cloudflare-dns.com, dns.quad9.net…), which the router resolves by itself, and two forward rules that close port 443 TCP and UDP toward that list. As a reinforcement, the tls-host matcher at the top of the chain.
How do I block DNS over TLS?
By closing port 853 in forward, TCP for DoT and UDP for DNS over QUIC. The reject with tcp-reset sends devices in automatic mode back to normal DNS right away.
Why doesn’t the tls-host rule block anything?
Usually because it’s after the fasttrack or after the accept established: the first TLS packet belongs to an already established connection and gets accepted first. It has to be moved to the top. Also, it doesn’t work with connections to an IP address with no name, nor when the first TLS packet is split into several segments.
How do I disable Firefox’s automatic DoH across the whole network?
By having the router’s DNS answer “it doesn’t exist” to the name use-application-dns.net, with /ip dns static add name=use-application-dns.net type=NXDOMAIN. It only works if the PCs use the router’s DNS and if the user hasn’t turned DoH on by hand.



