On this pageHow the RouterOS resolver works
Every RouterOS device includes a caching DNS resolver. On an office or home router it answers the LAN, serves local names and can filter ad and malware domains. On a MikroTik Cloud Hosted Router (CHR) with a public address, the same setting that makes it useful, allow-remote-requests=yes, turns it into an open resolver for the whole internet if the firewall is not ready. This guide configures the resolver on RouterOS 7 in the order that avoids that mistake.
How the RouterOS resolver works
The router always uses the servers in /ip dns for its own lookups: NTP, update checks, fetch jobs. Turning on allow-remote-requests makes it also answer other machines on UDP and TCP port 53, on every interface, unless firewall rules say otherwise. Answers are cached in memory, 2,048 KiB by default, for at most one week by default (cache-max-ttl).
Servers learned from a DHCP client or PPPoE session appear as dynamic-servers next to the ones you set by hand. Check the current state before changing anything:
/ip dns print
The settings you will touch most, with their defaults:
| Property | Default | What it controls |
|---|---|---|
servers |
empty | Upstream resolvers, IPv4 or IPv6, comma-separated |
allow-remote-requests |
no |
Whether other machines may query the router |
cache-size |
2048 KiB | Memory reserved for cached answers |
cache-max-ttl |
1 week | Upper limit on how long any answer is kept |
use-doh-server |
empty | A DNS over HTTPS upstream, which takes over from servers once it works |
verify-doh-cert |
no |
Whether the DoH server's certificate is checked |
query-server-timeout |
2 s | How long to wait for one upstream server |
When a query arrives, the router checks its static entries first (regular-expression entries before plain names), then the cache, and only then asks an upstream server. That order is why a forgotten static entry can override a public record for months: no cache flush will touch it.
Step 1: close port 53 to the internet
Do this first. Home and office routers that still run MikroTik's default configuration already drop input traffic that does not come from the LAN. A CHR, or a device reset without the default configuration, has no firewall rules at all.
Put the WAN interface in an interface list if it is not in one already, then drop DNS from that list for IPv4 and IPv6:
/interface list add name=WAN
/interface list member add list=WAN interface=ether1
/ip firewall filter add chain=input in-interface-list=WAN protocol=udp dst-port=53 action=drop comment="no DNS from WAN" place-before=0
/ip firewall filter add chain=input in-interface-list=WAN protocol=tcp dst-port=53 action=drop comment="no DNS from WAN" place-before=0
/ipv6 firewall filter add chain=input in-interface-list=WAN protocol=udp dst-port=53 action=drop place-before=0
/ipv6 firewall filter add chain=input in-interface-list=WAN protocol=tcp dst-port=53 action=drop place-before=0
place-before=0 puts each rule at the top of the input chain, so an earlier accept rule cannot shadow it. MikroTik's own documentation recommends limiting port 53 to known hosts whenever remote requests are enabled. An open resolver gets found quickly and abused to amplify DDoS floods against third parties, with your router's address as the source.
Step 2: upstream servers and the cache
Now set the upstream servers and allow LAN clients to use the router:
/ip dns set servers=1.1.1.1,9.9.9.9,2606:4700:4700::1111 allow-remote-requests=yes cache-size=4096KiB
Two upstream providers keep names resolving when one has trouble, and an IPv6 entry helps on networks where IPv6 is the better path. A larger cache costs little on most devices and keeps popular answers local.
If you want only these servers, stop the WAN DHCP client from adding the provider's resolvers:
/ip dhcp-client set [find interface=ether1] use-peer-dns=no
From outside your network, query the router's public address: dig @203.0.113.1 example.com should time out. Run that test only against routers you own.
Step 3: static records for local names
Static entries give devices on the LAN stable names. Use home.arpa, the suffix reserved for home networks, or a subdomain of a domain you own. Avoid .local, which belongs to multicast DNS.
/ip dns static add name=router.home.arpa address=192.168.88.1
/ip dns static add name=nas.home.arpa address=192.168.88.10 ttl=1h
/ip dns static add name=files.home.arpa type=CNAME cname=nas.home.arpa
/ip dns static print
RouterOS 7 supports A, AAAA, CNAME, MX, NS, SRV, TXT and NXDOMAIN entries, plus FWD, which sends a whole domain to another server. That is how you resolve names behind a VPN or an Active Directory domain without making the internal server your main resolver:
/ip dns static add name=corp.example.com type=FWD forward-to=10.10.0.53 match-subdomain=yes
Entries can also match a regular expression with regexp=, but every query is tested against them, so keep regex entries few.
Step 4: encrypt upstream queries with DNS over HTTPS
DoH hides your queries from the networks between the router and the resolver. The router must be able to verify the DoH server's certificate, which means it needs trusted root certificates. One common approach is the CA bundle that the curl project publishes:
/tool fetch url=https://curl.se/ca/cacert.pem
/certificate import file-name=cacert.pem passphrase=""
/ip dns set use-doh-server=https://cloudflare-dns.com/dns-query verify-doh-cert=yes
The fetch itself happens before the router trusts anything, so compare the file against the checksum curl publishes next to it, or upload the bundle from a machine you trust. Keep the plain servers entries: the router needs them to resolve the DoH server's own hostname, and once DoH works it takes precedence. RouterOS supports one DoH server at a time, and its documentation lists some providers, including Quad9 and Mullvad, as incompatible. Check the result in the log:
/log print where topics~"dns"
Certificate errors usually mean a missing root certificate or a wrong clock. Make sure the NTP client is enabled before blaming the provider.
Step 5: block ad and malware domains with an adlist
Recent RouterOS 7 releases can load hosts-format blocklists directly:
/ip dns adlist add url=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts ssl-verify=yes
/ip dns adlist print
The router checks each list for updates about every four hours, and print shows how many names were loaded and how often they matched. Lists live in memory, so on small devices start with one well-maintained list rather than stacking several.
Step 6: make LAN clients use the router
Hand out the router's address in DHCP:
/ip dhcp-server network set [find address="192.168.88.0/24"] dns-server=192.168.88.1
Some devices ignore DHCP and query a hard-coded public resolver. A destination NAT rule can redirect plain DNS from the LAN to the router:
/ip firewall nat add chain=dstnat in-interface-list=LAN protocol=udp dst-port=53 action=redirect to-ports=53
/ip firewall nat add chain=dstnat in-interface-list=LAN protocol=tcp dst-port=53 action=redirect to-ports=53
It cannot catch applications that use DNS over HTTPS themselves, which look like ordinary HTTPS traffic.
Inspect and flush the cache
/ip dns cache print
/ip dns cache flush
Flush after changing static entries or adlists if clients still get old answers, then flush the clients too, as described in the guide to clearing DNS caches.
Running RouterOS in the cloud
A CHR on a VPS is handy as a VPN concentrator or a resolver for remote sites, and it is exactly the case where step 1 matters most. CloudSat offers MikroTik RouterOS as an OS image and MikroTik CHR as a one-click app; on either, add the WAN rules before you set allow-remote-requests=yes.
FAQ
Do I need allow-remote-requests at all?
Only if other devices use the router as their resolver. A router that just routes traffic can leave it off and still resolve names for its own needs.
Why do clients still get the old address after I changed a static entry?
They cached the previous answer. Lower the entry's ttl before planned changes, flush the router cache, and flush or reconnect the client.
Can the router serve DNS over HTTPS to my LAN?
No. The DoH setting covers the router's upstream queries only. LAN clients still talk plain DNS to the router, which stays inside your network.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




