How Can We Help?

DNS scripting

< All Topics

The DNS settings of RouterOS can be managed within your scripts for different goals.

If you want to automate the DNS service configuration you have a simple command that can be used :

# Mikrotik Routerboard : Set DNS Google servers
/ip dns set servers=8.8.8.8,8.8.4.4;

You can also automate the creation of static DNS entries in your device (for filtering for example), with two options :
– direct domain
– Regular expression

The first option will allow to blacklist a predefined domain and only this domain

# Mikrotik Routerboard : Set the DNS configuration to enable Google Safesearch
/ip dns static add address=216.239.38.120 ttl=30m comment=Safsearch name=www.google.com;

The regular expression is quite more powerful because the match can be defined with a POSIX expression, which is very adapted to enforce DNS blacklist for a given domain or application

# Mikrotik Routerboard : DNS Blacklist for Twitch
/ip dns static add address=192.168.88.1 ttl=5m comment=$dnsgroup regexp=”.*\.twitch\.tv”;

Table of Contents