Automatic Controller Assignment for Unifi DHCP Option 43 on Mikrotik Routers

Jay Rogers avatar
Jay Rogers September 13th, 2017

Managing many network devices can be a pain. Especially if you need to simply plug a device in and repeat the steps to configure your the device. Thankfully, Ubiquiti’s controllers can be autmatically discovered and joined to Unifi using DHCP Option 43.

In this article, we’ll go through configuring a Mikrotik Router that is running Routerboard 3.x (my version that I am using at this time of the article).

Step 1: Configure your Unifi controller

A few things to remember before getting started:

  1. Make sure your Unifi controller is always running (using a cloud key or a computer that is dedicated to serving the network with the Unifi Controller services)
  2. Make sure your Unifi controller has a static IP address (this is very important). It can be a local static IP address, or a WAN static IP address. Whatever IP address it is, your devices must be able to access this IP and it cannot change

Step 2: Configure your DHCP Server in Routerboard

After you have your controller up and running, you will want to sign into your Mikrotik router. For simplicity sake, I am using Winbox (available on Windows [see download at bottom of this page] or Mac OS X).

  • Once logged in, on the left sidebar go to “IP > DHCP Server”.
  • At the top, you will find a tab called “Options”. Click the “+” sign to create a new option.

This is where things get fun…

Step 3: Convert your IP address to hexadecimal

Don’t screw this step up because it is kind of confusing. Take your static IP address (for my example, I am going to use 192.168.1.200) and convert it to hexadecimal format using the IP to Hex Converter tool.

You’ll see your result below, but we need to modify it yet:

We need to take our result (in my case 0xC0A801C8) and add 0104 after the x in the hexdecimal result that was created for us on the IP to Hex Converter tool.

This will give me a final result of: 0x0104C0A801C8

Why 0104? This is how the documentation explains it:

Going back to the “New DHCP Option screen, configure your options with the following options:

Name: unifi
Code: 43
Value: {{ your "final result" after modifying your hexadecimal IP }}

It should look like this once you are complete:

Step 4: Configure your DHCP network to use the “unifi” option

Under “IP > DHCP Server” then under the “Networks” tab, you will see a list of all your available DHCP networks. Double click on your network and assign it the unifi option that we just created.

Step 5: Plug in your *factory default* device

Now all you need to do is plug in your factory default device and connect it to your network. If you have a device that belonged to a different network or controller, reset the device first. When your device is booted and connected to your network, open up your controller. You should see a new device that is awaiting adoption.

Click “Adopt” and all your network settings will be applied to that device. This method has saved me countless hours of going on site and makes device upgrades painless. It’s so easy, even my grandmother can do this (literally). All you need to do from this point forward is have the device on and plugged into the network and you can manage it anywhere in the world.

If you found this article helpful or if you have any questions, drop a comment below!

Support future content

The Ultimate Guide to Building APIs and Single-Page Applications with Laravel + VueJS + Capacitor book cover.

Psst... any earnings that we make off of our book is being reinvested to bringing you more content. If you like what you read, consider getting our book or get sweet perks by becoming a sponsor.

Written By Jay

Jay Rogers avatar Jay Rogers

Iā€™m a DevOps engineer who accidentally ended up in application & user-experience design. ?? I'm a husband and proud dog-dad who co-founded 521 Dimensions & Server Side Up. I like to having meaningful conversations with people who love building things. Please reach out and say hello!

Like this? Subscribe

We're privacy advocates. We will never spam you and we only want to send you emails that you actually want to receive. One-click unsubscribes are instantly honored.