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=,;

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= 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= ttl=5m comment=$dnsgroup regexp=”.*\.twitch\.tv”;

Previous Date and Time scripting
Next Speedtest
Table of Contents