DNS Client and Cache

Document revision:1.2 (Fri Apr 15 17:37:43 GMT 2005)
Applies to: V2.9

General Information


DNS cache is used to minimize DNS requests to an external DNS server as well as to minimize DNS resolution time. This is a simple recursive DNS server with local items.


Packages required: system
License required: Level1
Submenu level: /ip dns
Standards and Technologies: DNS
Hardware usage: Not significant

Related Documents


The MikroTik router with DNS cache feature enabled can be set as a primary DNS server for any DNS-compliant clients. Moreover, MikroTik router can be specified as a primary DNS server under its dhcp-server settings. When the DNS cache is enabled, the MikroTik router responds to DNS TCP and UDP requests on port 53.

Additional Resources

Client Configuration and Cache Setup

Submenu level: /ip dns


DNS client is used to provide domain name resolution for router itself as well as for the P2P clients connected to the router.

Property Description

allow-remote-requests (yes | no) - specifies whether to allow network requests

cache-max-ttl (time; default: 1w) - specifies maximum time-to-live for cahce records. In other words, cache records will expire after cache-max-ttl time.

cache-size (integer: 512..10240; default: 2048KiB) - specifies the size of DNS cache in KiB

cache-used (read-only: integer) - displays the currently used cache size in KiB

primary-dns (IP address; default: - primary DNS server

secondary-dns (IP address; default: - secondary DNS server


If the property use-peer-dns under /ip dhcp-client is set to yes then primary-dns under /ip dns will change to a DNS address given by DHCP Server.


To set as the primary DNS server and allow the router to be used as a DNS server, do the following:

[admin@MikroTik] ip dns> set primary-dns= \
\... allow-remote-requests=yes
[admin@MikroTik] ip dns> print
  allow-remote-requests: yes
             cache-size: 2048KiB
          cache-max-ttl: 1w
             cache-used: 17KiB
[admin@MikroTik] ip dns>

Cache Monitoring

Submenu level: /ip dns cache

Property Description

address (read-only: IP address) - IP address of the host

name (read-only: name) - DNS name of the host

ttl (read-only: time) - remaining time-to-live for the record

Static DNS Entries

Submenu level: /ip dns static


The MikroTik RouterOS has an embedded DNS server feature in DNS cache. It allows you to link the particular domain names with the respective IP addresses and advertize these links to the DNS clients using the router as their DNS server.

Property Description

address (IP address) - IP address to resolve domain name with

name (text) - DNS name to be resolved to a given IP address

ttl (time) - time-to-live of the DNS record


To add a static DNS entry for www.example.com to be resolved to IP address:

[admin@MikroTik] ip dns static> add name www.example.com address=
[admin@MikroTik] ip dns static> print
 # NAME                                                   ADDRESS         TTL
 0 aaa.aaa.a                                     1d
 1 www.example.com                                      1d
[admin@MikroTik] ip dns static>

Flushing DNS cache

Command name: /ip dns cache flush

Command Description

flush - clears internal DNS cache


[admin@MikroTik] ip dns> cache flush
[admin@MikroTik] ip dns> print
    allow-remote-requests: yes
               cache-size: 2048 KiB
            cache-max-ttl: 1w
               cache-used: 10 KiB
[admin@MikroTik] ip dns>