How to Set Up a MikroTik DHCP Server in Winbox

Aisyah Aldina

Illustration of a mailbox for a guide on how to set up a MikroTik DHCP server in Winbox

Hi everyone, in this post I want to show you how to set up a MikroTik DHCP server in Winbox. A DHCP server hands out IP addresses, the gateway, and DNS automatically to every device that joins the network. Without one, you would have to configure the IP on every laptop, PC, or phone by hand, and that gets painful very quickly on a busy network.

This article continues the guide on MikroTik basic configuration with Winbox for beginners. Back there the client was still using a static IP, so now we will change things so the client gets its IP automatically from MikroTik. I am using a MikroTik CHR running RouterOS 7.25.2 with the LAN on ether2 (192.168.56.10/24) and a Linux Mint client. Halfway through the lab I also ran into a real problem: another DHCP server on the same network was handing out IPs too.

Create the DHCP Server with DHCP Setup

Open IP and then DHCP Server

Opening the IP menu and then DHCP Server in WinBox

Click the IP menu and then choose DHCP Server.

Click DHCP Setup

Empty DHCP Server window with the DHCP Setup button in the Actions panel

The DHCP Server window is still empty. Click DHCP Setup in the Actions panel on the right. This wizard creates the pool, the network, and the server in one go, so it is safer for beginners than building each part separately.

Choose the LAN interface

Choosing ether2 as the DHCP Server Interface and clicking Next

The default choice is ether1, but ether1 is the WAN. Change DHCP Server Interface to ether2 (labeled LAN), then click Next. Never put the DHCP server on the WAN port, because it could start handing out IPs to the ISP network.

Check the address space

DHCP Address Space 192.168.56.0/24 filled in automatically from the ether2 IP

DHCP Address Space is filled in automatically with 192.168.56.0/24, taken from the IP assigned to ether2. Click Next.

Check the gateway

Gateway for DHCP Network set to 192.168.56.10

Gateway for DHCP Network is set to 192.168.56.10, which is the router IP. This is the gateway the clients will use to reach the internet. Click Next.

Watch out for the default IP range

The wizard default range includes IPs already in use on the network

In the Addresses to Give Out step, the wizard suggests 192.168.56.1-192.168.56.9 and 192.168.56.11-192.168.56.254, which is every IP except the router’s. The problem is that on my network 192.168.56.1 is already taken by the admin laptop and 192.168.56.20 is used by the static client. If you leave it like this, DHCP can hand out IPs that are already in use.

Change the IP range

Changing Addresses to Give Out to 192.168.56.100-192.168.56.200

Remove the second line with the minus button, then change the range to 192.168.56.100-192.168.56.200. That way IPs 1 to 99 stay free for devices you configure manually, such as routers, servers, or printers. Click Next.

Tick Send DNS

Ticking Send DNS so the DHCP server sends DNS to clients

RouterOS 7.25 has a Send DNS step. Tick it so the DHCP server also sends the DNS address to clients, then click Next.

Use the router IP as DNS

Setting DNS Servers to the router IP 192.168.56.10

The wizard suggests the ISP DNS. I replaced it with the router IP 192.168.56.10, because the router already serves DNS with Allow Remote Requests enabled. Click Next.

Keep the lease time

Default Lease Time 00:30:00 in DHCP Setup before clicking Next

The default Lease Time is 00:30:00, or 30 minutes, which matches the default value in the MikroTik documentation. It means a client borrows the IP for 30 minutes and then renews it automatically. Click Next to finish the wizard.

The DHCP server is ready

DHCP server dhcp1 created on ether2 with the pool dhcp_pool0

A DHCP server named dhcp1 now shows up on interface ether2 with Lease Time 00:30:00 and Address Pool dhcp_pool0.

Check the Networks tab

Networks tab showing 192.168.56.0/24 with gateway and DNS 192.168.56.10

Open the Networks tab. You will see the network 192.168.56.0/24 with gateway 192.168.56.10 and DNS server 192.168.56.10. This is the information that gets sent to the clients.

Testing from the Client and the Problem I Found

On the Linux Mint client, I switched the IP settings from manual to automatic (DHCP).

sudo nmcli con mod "Wired connection 1" ipv4.method auto ipv4.addresses "" ipv4.gateway "" ipv4.dns ""
sudo nmcli con up "Wired connection 1"
ip -4 addr show enp0s3; ip route; resolvectl dns enp0s3

On Windows, just choose Obtain an IP address automatically in the IPv4 settings of the network adapter.

The client gets the wrong IP

Client gets the IP 192.168.56.101 with no gateway from VirtualBox DHCP instead of MikroTik

The client did get the IP 192.168.56.101, but something looked off. The lease was only 588 seconds (about 10 minutes) even though our server uses 30 minutes, there was no default route, and DNS was empty. That means this IP did not come from MikroTik, it came from another DHCP server on the same network.

Find the other DHCP server

Built-in VirtualBox Host-only DHCP Server still enabled at 192.168.56.100

In my lab, the culprit was the built-in VirtualBox DHCP server for the Host-only network, which was enabled at 192.168.56.100 and handing out 192.168.56.101 to 192.168.56.254. On a real network, the same thing can happen because of a WiFi router or another modem that still has its DHCP turned on.

Turn off the other DHCP server

Unticking Enable Server and clicking Apply to turn off VirtualBox DHCP

I opened File, Tools, Network in VirtualBox, selected the Host-only adapter, went to the DHCP Server tab, unticked Enable Server, and clicked Apply. For an extra WiFi router or modem, turn off its DHCP server or set that device up as an access point only.

The client gets its IP from MikroTik

Client gets its IP from MikroTik with a default route and DNS 192.168.56.10

After disconnecting and reconnecting the client, the result was correct. The lease is 1786 seconds (almost 30 minutes), there is default via 192.168.56.10 proto dhcp, and the DNS is 192.168.56.10. This time the IP really comes from MikroTik.

My experience: At first I thought the MikroTik DHCP server was already working because the client got an IP right away. Only after noticing the 10 minute lease and the missing gateway did I realize there was another DHCP server. So when you test, do not just look at the IP, check the gateway, DNS, and lease time as well.

Managing Leases

View the client lease

Client lease with the D flag before clicking Make Static

Open the Leases tab in the DHCP Server window. The client shows up with the IP 192.168.56.101, its MAC address, and the D flag, which means dynamic. A dynamic IP can change if the client stays disconnected for a long time.

Lock the IP with Make Static

Lease 192.168.56.101 is now static after Make Static

To make sure the client always gets the same IP, select that lease and click Make Static in the Actions panel. You will see the notification Action Make Static ok and the D flag disappears. This works well for printers, CCTV cameras, or servers that need a fixed IP but should still get it through DHCP.

Why the DHCP Server Status Is Invalid

An example of the invalid status

DHCP server with the I invalid flag and the message No IP address on interface

To show this, I disabled the IP 192.168.56.10 on ether2. The DHCP server immediately got the I (invalid) flag with the red message No IP address on interface. According to the MikroTik documentation, a DHCP server is marked invalid when its configuration is not valid, for example when the interface has no IP address.

Enable the IP again

Enabling the IP 192.168.56.10 again so the DHCP server is back to normal

After enabling the IP 192.168.56.10 again in IP Addresses with the Enable button, the I flag on dhcp1 disappears and the DHCP server goes back to normal.

Test the internet from the client

DHCP client successfully pings google.com with 0 percent packet loss
ping -c 3 google.com

The client that got its IP from the MikroTik DHCP server can ping google.com with 0% packet loss, which means the IP, gateway, and DNS it received are all correct.

Common Problems and How to Fix Them

The DHCP server status is invalid

The most common causes are that the interface has no IP, the IP is disabled, or the interface is not running. If the port is already a member of a bridge, put the DHCP server on the bridge, not on the port. The MikroTik documentation also notes that a DHCP server does not work properly on an empty bridge.

The client gets an IP but has no internet

Check whether the IP really comes from MikroTik by looking at the gateway and lease time. If the gateway is empty or different, there is probably another DHCP server on the network. If the gateway is correct, check the NAT masquerade rule as shown in the basic configuration article.

The client does not get an IP at all

Make sure the DHCP server is on the right interface and is not disabled. Also make sure the pool is not used up. The pool 192.168.56.100-200 only holds 101 IPs, so make the range bigger if you have a lot of devices.

The client IP conflicts with another device

Do not put IPs used by static devices inside the pool. Keep the ranges separate, for example 1 to 99 for static devices and 100 and up for DHCP, just like the example in this article.

That is it, your MikroTik DHCP server is now handing out IPs, the gateway, and DNS automatically, and you also know how to give a client a fixed IP and how to deal with the invalid status. In the next article we will take a deeper look at NAT masquerade. If your clients still are not getting an IP, describe what you are seeing in the comments below.

Leave a Comment