Come hang with us on Discord and chat directly with the team!Discordtop-bar-close-icon

2024-09-17

DNS Setup on MikroTik: A Quick Guide to MikroTik DNS Server

tutorials
img

Have you ever wondered how exactly hostnames are linked to IP addresses? Like, how is this process happening? Or, even more specifically, how do we avoid memorizing long IP addresses and complex alphanumerics in the IPV6 system? In a nutshell, DNS Server is the answer to these questions. This article will introduce essential concepts and discuss the MikroTik DNS server and its setup. So, you can use this step-by-step tutorial to understand how to do DNS configuration on MikroTik.

What is DNS & How Does It work?

Domain Name Server (DNS) is essential for a computer network, meaning that there is no possibility of web communication without its presence.

A DNS converts domain names into IP addresses, allowing browsers to access different websites and other internet resources. You can use IP Addresses to locate every device on the internet. But instead of memorizing a long list of IP addresses, you can enter the website’s name, and then the DNS gets its IP address for you. MikroTik Router has both DNS Client and DNS Server features. The Mikrotik DNS Server has features that provide domain name resolution for the clients connected to it.

What are the benefits of using a DNS server?

A Domain Name System is a centralized utility that gives the IP addresses a domain name. Here’s a list of the advantages of DNS servers:

  • DNS is the only system that allows online users to browse and use the internet.
  • Only by typing the name of websites DNS servers help you in finding the website using your web browser (like Chrome, Safari, Firefox, and Internet Explorer).
  • You don’t need to memorize numbers. Meaning that, Instead of IP addresses or a string of numbers, you enter the domain name or URL; this makes searching through the internet easier for you.
  • DNS servers make online transactions possible.
  • DNS servers let you identify the data service’s technical functionality, defining the DNS protocol, detailed data structures specification, and data communication exchanges. Moreover, DNS adds an extra layer of security, making the process much safer.
  • DNS enhances the security of DNS infrastructure, which is an essential factor for dynamic, secure updates.
  • When customers visit your website, they will experience more reliable, secure, and faster online transactions.

VPS and MikroTik — Do I need One?

A Virtual Private Server is a virtual machine created on a powerful physical server. Each VPS owns a dedicated part of the host server’s resources like RAM, CPU, and storage. You can choose any operating system you prefer from the various options we provide, or you can upload your own custom ISO, including RouterOS. The benefit of having a VPS as your router is that you don’t have to dedicate a whole computer to it. You can use your own home laptop and connect to your MikroTik VPS and use it as your Router. Unlike your home computer, this VPS will be online and working 24/7, with internet connection and power provided by the data center, meaning that you wouldn’t need an expensive internet provider, do not need to keep your home computer on all the time, and no extra cost will be billed for electricity.

DNS configuration on MikroTik step-by-step tutorial

The following steps will show you how to configure the DNS service in MikroTik Router.

Step 1: Open Winbox and connect to your MikroTik

Winbox is a useful utility that allows the administration of MikroTik RouterOS using a fast and simple GUI.

ip dns set servers=8.8.8.8,8.8.4.4 allow-remote-requests=yes max-udp-packet-size=4096 query-server-timeout=2.000 query-total-timeout=10.000 cache-size=2048 cache-max-ttl=7d

How to Configure DNS in MikroTik using the terminal?

Setting up the MikroTik DNS server configuration with the terminal is pretty simple. Here is what you should do:

  • Step 1: First, you must connect to your MikroTik by SSH or console.
  • Step 2: Then, you should enter the above command to enable DNS and its configuration.

How to Put Static DNS Entry in MikroTik Cache DNS?

Whenever MikroTik cache DNS gets a new domain, it dynamically stores DNS entry. But occasionally, you may want to put static host entries like your local servers or even printers. To address this, MikroTik cache DNS enables you to enter static hosts. The following steps will describe putting static host entry in MikroTik DNS Server.

  • Click on “Static” button, From “DNS Settings” window.
  • Click on “PLUS SIGN (+)“. A new DNS Static Entry window will appear.
  • Put your hostname (like FTP) in the Name input field and the host’s IP Address in the Address input field.
  • Finally, Click Apply and OK button.

How to Block DNS Request from WAN Interface?

If you turn your MikroTik router into a DNS server, all of your MikroTik IP addresses can be used as DNS servers. You can even use WAN IP (a public IP), which is a problem. Because if people outside of your LAN use your WAN IP as a DNS IP, your MikroTik will provide them DNS solutions, and it would be consuming your paid bandwidth.

So, you have to stop DNS requests from outside of your LAN. To stop DNS requests outside of your LAN, you should apply firewall rules. Firewall rules can help you drop all DNS requests from your WAN interface. The following steps will guide you on how to block DNS requests from the WAN interface:

  • Go to “IP > Firewall” menu and click on “PLUS SIGN (+)“.
  • From “General” tab, select input from the Chain drop-down menu, choose “UDP” from the Protocol drop-down menu and put 53 in “Dst. Port input box” and then choose your WAN Interface (like ether1) from “In. Interface” drop-down menu.
  • Click on “Action” tab and choose drop option from “Action” drop-down menu.
  • Click on Apply and OK button.
  • Again, click on PLUS SIGN (+), choose input from the Chain drop-down menu, choose “TCP” from the Protocol drop-down menu, and put 53 in Dst. Port input box and then choose your WAN Interface from In. Interface drop-down menu.
  • At last, click Apply and OK button.