REFERENCE

v6.11.0

DNS

DNS settings, static records, cache and regexp (`/ip dns`).

Tools

set_dns_servers

Configure DNS Resolver Settings · Risk: write

Configures the DNS resolver (/ip dns set) — sets upstream server IPs, enables or disables forwarding client queries to this router (allow_remote_requests), tunes cache limits (cache_size in KiB, cache_max_ttl, max_udp_packet_size, max_concurrent_queries), and optionally switches to DNS-over-HTTPS (use_doh=true + doh_server URL + verify_doh_cert). Use this when you need to CHANGE which servers the router queries or how its resolver behaves. To read current settings without changing them use get_dns_settings. Returns the updated /ip dns print output after applying changes.

ParameterRequiredDefinition
serversYesDNS server IP addresses {"type":"array","items":{"type":"string"}}
allow_remote_requestsYes{"default":false,"type":"boolean"}
max_udp_packet_sizeNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
max_concurrent_queriesNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
max_concurrent_tcp_sessionsNoMaximum number of simultaneous TCP DNS sessions {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
query_server_timeoutNoPer-upstream-server query timeout, e.g. "2s" {"type":"string"}
query_total_timeoutNoTotal query timeout across all servers, e.g. "10s" {"type":"string"}
cache_sizeNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
cache_max_ttlNo{"type":"string"}
use_dohYes{"default":false,"type":"boolean"}
doh_serverNo{"type":"string"}
verify_doh_certYes{"default":true,"type":"boolean"}
doh_max_server_connectionsNoMaximum concurrent connections to the DoH server {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
doh_max_concurrent_queriesNoMaximum concurrent queries over DoH {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
doh_timeoutNoDoH request timeout, e.g. "5s" {"type":"string"}
vrfNoVRF the resolver uses for upstream queries {"type":"string"}

get_dns_settings

Get DNS Resolver Settings · Risk: read

Reads the current DNS resolver configuration (/ip dns print) — upstream server IPs, allow-remote-requests flag, cache-size, cache-max-ttl, max-udp-packet-size, max-concurrent-queries, and DNS-over-HTTPS settings. To change these settings use set_dns_servers. For cache entry counts and utilization metrics use get_dns_cache_statistics. Returns the full /ip dns print settings block.

No tool-specific parameters.

add_dns_static

Add DNS Static Record · Risk: write

Creates a static DNS record in /ip dns static — the local override table that answers DNS queries before upstream resolvers are consulted. Supports A (address), CNAME (cname), MX (mx_preference + mx_exchange), TXT (text), and SRV (srv_priority + srv_weight + srv_port + srv_target) record types; provide exactly one record type's fields per call. A regexp pattern may also be set for wildcard hostname matching — for a simpler regexp-only interface use add_dns_regexp instead. To inspect existing records use list_dns_static. Returns the created entry's full detail including its .id.

ParameterRequiredDefinition
nameYes{"type":"string"}
typeNoRecord type, e.g. "A", "AAAA", "CNAME", "NS", "FWD", "MX", "SRV", "TXT" {"type":"string"}
addressNo{"type":"string"}
cnameNo{"type":"string"}
nsNoName server FQDN for an NS-type record {"type":"string"}
forward_toNoDNS server to forward to for a FWD-type record {"type":"string"}
match_subdomainNoAlso match all subdomains of name/regexp {"type":"boolean"}
address_listNoAdd resolved addresses to this firewall address-list {"type":"string"}
mx_preferenceNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
mx_exchangeNo{"type":"string"}
textNo{"type":"string"}
srv_priorityNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
srv_weightNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
srv_portNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
srv_targetNo{"type":"string"}
ttlNo{"type":"string"}
commentNo{"type":"string"}
disabledYes{"default":false,"type":"boolean"}
regexpNo{"type":"string"}

list_dns_static

List DNS Static Records · Risk: read

Lists static DNS records from /ip dns static print — the local resolver override table. Supports optional filters: name_filter (substring match on hostname), address_filter (substring match on IP), type_filter (exact record type, e.g. "A", "CNAME", "MX"), disabled_only (only disabled entries), regexp_only (only regexp-pattern entries). To retrieve full field detail for one specific entry by .id use get_dns_static. Returns a table of all matching static DNS records with their .id values.

ParameterRequiredDefinition
name_filterNo{"type":"string"}
address_filterNo{"type":"string"}
type_filterNo{"type":"string"}
disabled_onlyYes{"default":false,"type":"boolean"}
regexp_onlyYes{"default":false,"type":"boolean"}

get_dns_static

Get DNS Static Record Detail · Risk: read

Retrieves full detail of a single static DNS record (/ip dns static print detail where .id=…). Use when you need all field values for one known entry rather than a table of all records. The entry_id is the .id returned by list_dns_static. For a table of all records (or to search by name/address/type) use list_dns_static. Returns the full detail output for the specified entry, or a not-found message.

ParameterRequiredDefinition
entry_idYes{"type":"string"}

update_dns_static

Update DNS Static Record · Risk: write-idempotent

Modifies fields on an existing static DNS record (/ip dns static set) — can update the hostname (name), record-type data (address, cname, mx_preference, mx_exchange, text, srv fields), ttl, comment, disabled state, or regexp pattern. Pass an empty string for a field to clear it (e.g. address="" removes the address field). The entry_id is the .id from list_dns_static. To activate or deactivate without touching other fields use enable_dns_static or disable_dns_static. Returns the updated entry's full detail.

ParameterRequiredDefinition
entry_idYes{"type":"string"}
nameNo{"type":"string"}
typeNoRecord type, e.g. "A", "AAAA", "CNAME", "NS", "FWD", "MX", "SRV", "TXT" {"type":"string"}
addressNo{"type":"string"}
cnameNo{"type":"string"}
nsNoName server FQDN for an NS-type record {"type":"string"}
forward_toNoDNS server to forward to for a FWD-type record {"type":"string"}
match_subdomainNoAlso match all subdomains of name/regexp {"type":"boolean"}
address_listNoAdd resolved addresses to this firewall address-list {"type":"string"}
mx_preferenceNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
mx_exchangeNo{"type":"string"}
textNo{"type":"string"}
srv_priorityNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
srv_weightNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
srv_portNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
srv_targetNo{"type":"string"}
ttlNo{"type":"string"}
commentNo{"type":"string"}
disabledNo{"type":"boolean"}
regexpNo{"type":"string"}

remove_dns_static

Remove DNS Static Record · Risk: destructive

Permanently deletes a static DNS record from /ip dns static — verifies the entry exists first via a count-only check, then runs /ip dns static remove. The entry_id is the .id from list_dns_static. To temporarily suppress a record without deleting it use disable_dns_static. Returns confirmation of deletion, or a not-found message if the ID does not exist.

ParameterRequiredDefinition
entry_idYes{"type":"string"}

enable_dns_static

Enable DNS Static Record · Risk: write-idempotent

Re-activates a disabled static DNS record (/ip dns static set disabled=no) so it participates in local DNS resolution again. The entry_id is the .id from list_dns_static. To suppress a record temporarily use disable_dns_static. To permanently delete use remove_dns_static. Returns the updated entry's full detail.

ParameterRequiredDefinition
entry_idYes{"type":"string"}

disable_dns_static

Disable DNS Static Record · Risk: write-idempotent

Deactivates a static DNS record (/ip dns static set disabled=yes) without deleting it — the entry is retained but ignored during resolution. The entry_id is the .id from list_dns_static. To re-activate use enable_dns_static. To permanently delete use remove_dns_static. Returns the updated entry's full detail.

ParameterRequiredDefinition
entry_idYes{"type":"string"}

get_dns_cache

Get DNS Cache Entries · Risk: read

Lists all hostnames currently held in the router's DNS resolver cache (/ip dns cache print). Use to inspect what the router has already resolved and what is available without re-querying upstream servers. For summary statistics (cache-size, cache-used, cache-max-ttl, total entry count) use get_dns_cache_statistics. To clear the cache use flush_dns_cache. Returns the full cache table, or a message if the cache is empty.

No tool-specific parameters.

flush_dns_cache

Flush DNS Cache · Risk: destructive

Clears all cached DNS entries from the router's resolver (/ip dns cache flush) — forces the router to re-query upstream servers for all subsequent lookups. Use after changing upstream servers or adding static records to evict stale cached responses. To inspect the cache before flushing use get_dns_cache. Returns confirmation of the flush.

No tool-specific parameters.

get_dns_cache_statistics

Get DNS Cache Statistics · Risk: read

Reports DNS cache utilization metrics — extracts cache-size, cache-used, and cache-max-ttl from /ip dns print, then appends the live count of cached entries from /ip dns cache print count-only. Use to assess cache utilization without listing every entry. Works on RouterOS v6 and v7 (there is no /ip dns cache print stats command). To see all cached entries use get_dns_cache. To change cache-size or cache-max-ttl use set_dns_servers. Returns cache-related fields and the total entry count.

No tool-specific parameters.

add_dns_regexp

Add DNS Regexp Static Record · Risk: write

Creates a regexp-pattern static DNS record (/ip dns static add) that matches any hostname satisfying the given regular expression and resolves it to a fixed IP address (IPv4 or IPv6) — useful for wildcard domains, captive portals, or ad-blocking. Simplified interface requiring only regexp (RouterOS regex) and address (IPv4 or IPv6), plus optional ttl (default 1d), comment, and disabled. For full record-type support (CNAME, MX, SRV, TXT) or to set both a hostname and regexp use add_dns_static. Returns the created entry's full detail including its .id.

ParameterRequiredDefinition
regexpYes{"type":"string"}
addressYes{"type":"string"}
ttlYes{"default":"1d","type":"string"}
commentNo{"type":"string"}
disabledYes{"default":false,"type":"boolean"}

test_dns_query

Test DNS Resolution From Router · Risk: read

Resolves a hostname using the router's own DNS resolver (:put [:resolve ...]) — tests what address the router itself would obtain for a given name. Optionally directs the query to a specific upstream server (IP). type is "A" (IPv4 only, default), "AAAA" (IPv6 only), "ANY" (IPv4 then IPv6 fallback), or "ANY6" (IPv6 then IPv4 fallback). Returns one resolved IP address, not all DNS records; MX queries are not supported. Use to verify DNS reachability, that a static record override is active, or that DoH is working — all from the router's perspective, not from a client behind it. Queries with an explicit server are not cached by RouterOS.

ParameterRequiredDefinition
nameYesDNS name to resolve, e.g. example.com {"type":"string","minLength":1}
serverNoOptional DNS server IP address {"type":"string","minLength":1}
typeYes{"default":"A","type":"string","enum":["A","AAAA","ANY","ANY6"]}

export_dns_config

Export DNS Configuration to File · Risk: read

Exports the full DNS configuration (resolver settings and static records) to a RouterOS script file on the router's flash storage (/ip dns export file=<filename>). The router appends .rsc to the filename automatically; defaults to dns_config.rsc. The exported file can be imported on another RouterOS device to replicate DNS configuration. To read current settings as structured output without writing a file use get_dns_settings. To list static records use list_dns_static. Returns the filename of the exported .rsc file on the router.

ParameterRequiredDefinition
filenameNo{"type":"string"}

On this page