Configuring DNS on RouterOS
DNS (Domain Name System) is what allows your router and network devices to resolve domain names like google.com into IP addresses. Without proper DNS configuration, your MikroTik router will not be able to browse the internet by name, and neither will devices behind it if you use the router as their DNS server.
This guide covers everything you need to know about setting up DNS on RouterOS v7 from scratch.
Setting DNS Servers
The first step is to tell your router which DNS servers to use. These are typically provided by your ISP, but you can also use public DNS servers like Google (8.8.8.8) or Cloudflare (1.1.1.1).
/ip dns set servers=8.8.8.8,8.8.4.4To verify the setting:
/ip dns printYou will see output similar to:
servers: 8.8.8.8,8.8.4.4
allow-remote-requests: no
cache-size: 2048KiB
cache-max-ttl: 1w
cache-used: 28KiBEnabling allow-remote-requests
By default, the router only resolves DNS for itself. If you want devices on your LAN to use the router as their DNS server, you must enable allow-remote-requests:
/ip dns set allow-remote-requests=yesThis tells the router to accept DNS queries from other hosts on the network. Once enabled, you can point your DHCP server to hand out the router's LAN IP (e.g., 192.168.1.1) as the DNS server for clients.
Security Note
When allow-remote-requests is enabled, make sure your firewall blocks DNS queries (UDP/TCP port 53) from the WAN interface so that external hosts cannot use your router as an open DNS resolver.
/ip firewall filter add chain=input action=drop protocol=udp dst-port=53 in-interface=ether1 comment="Block external DNS"
/ip firewall filter add chain=input action=drop protocol=tcp dst-port=53 in-interface=ether1 comment="Block external DNS TCP"Replace ether1 with your actual WAN interface name.
Static DNS Entries
Static DNS entries let you map hostnames to specific IP addresses manually. This is useful for internal services, so that devices on your network can reach a local server by name.
/ip dns static add name=nas.local address=192.168.1.50
/ip dns static add name=printer.local address=192.168.1.60To view all static entries:
/ip dns static printYou can also add CNAME-style aliases:
/ip dns static add name=files.local cname=nas.localDNS Caching Explained
RouterOS has a built-in DNS cache. When a client asks the router to resolve a domain, the router queries the upstream DNS server, gets the answer, and stores it locally for future requests. This reduces latency and saves bandwidth.
Cache Settings
- cache-size: How much memory to allocate for DNS cache (default 2048 KiB).
- cache-max-ttl: Maximum time a record is kept in cache (default 1 week). Records with shorter TTLs from the server will expire sooner.
To increase cache size:
/ip dns set cache-size=4096KiBTo check what is currently cached:
/ip dns cache printTo flush the DNS cache (useful after making static entry changes):
/ip dns cache flushUsing Multiple DNS Servers
You can specify multiple DNS servers separated by commas. RouterOS will try them in order:
/ip dns set servers=1.1.1.1,8.8.8.8,9.9.9.9Verifying DNS Resolution
Test that DNS is working correctly from the router itself:
/resolve google.comThis should return an IP address quickly. If it times out, check your WAN connection and your DNS server settings.
Summary
- Set upstream DNS servers with
/ip dns set servers=... - Enable
allow-remote-requests=yesto serve DNS to LAN clients - Add static entries with
/ip dns static add - Protect your DNS port from external access with firewall rules
- Monitor and flush the cache as needed with
/ip dns cache printand/ip dns cache flush
Proper DNS configuration is a foundation of a working network. Once set up, your router becomes a fast, local DNS resolver for all devices behind it.
