Reply
Emerging Member
Posts: 40
Registered: ‎04-07-2011
Kudos: 25
Solutions: 1

Mikrotik DHCP option 43 How to

After doing a lot of searching, I could not find an easy guide on how to add the option 43 to DHCP on a Mikrotik and get my APs to connect to a remote Controller so I figured I would write one.

My Setup:
Mikrotik 750 (v5.4 os) (Default config)
Unifi 2.2 controller on ubuntu VMWARE guest (Public IP: 192.168.200.10)

1. Convert your public IP to hex. The option 43 value has to be in HEX to work.
192=C0
168=A8
200=C8
10=0A
2. Your option 43 value will be "0x0104" + the HEX of the IP.
So in my example it is: "0x0104C0A8C80A"
3. Open up a new terminal on your Mikrotik or ssh in and type:
/ip dhcp-server option add code=43 name=unifi value=0x0104C0A8C80A
/ip dhcp-server network set 0 dhcp-option=unifi
My router was using the default config so only one network was present ID 0. You could do "/ip dhcp-server network print" to see the list and pick the ID of the network you want to add the option to.
4. Plug in your UAP and it should grab the info and show up on the remote Unifi controller asking to be adopted.

Troubleshooting:
Older UAPs have older firmware. The older firmware does not ask DHCP for option 43. Pulled my hair out for a few hours on this one. The way I found this was by turning on DHCP logging and watched the DHCP Discover. It was not asking for "VendorSpecific" which is option 43. If you have these you have a few options.
1. Upgrade the firmware in the lab by connecting them to a local Controller, adopting them and then "paper-clip" them.
2. Use the discovery tool on them to make them connect.
3. Use DNS. I prefer not to use this method but it does work even on older firmware. In your DHCP server config put in a domain name that you control. Then add a unifi A record pointing to the remote unif controller. Some will say this is easier than Option 43. However if you are doing many different controllers you would have to setup lots of sub-domains and such. And that domain will be default domain name on any hosts connecting on that network.
Regular Member
Posts: 553
Registered: ‎06-28-2011
Kudos: 68

Re: Mikrotik DHCP option 43 How to

Nice! That's even better than any info Ubnt has offered! They just sent a link to Cisco's info which wasn't too direct or helpful.
Ubiquiti Employee
Posts: 991
Registered: ‎05-04-2009
Kudos: 525
Solutions: 17
Contributions: 1

Re: Mikrotik DHCP option 43 How to


After doing a lot of searching, I could not find an easy guide on how to add the option 43 to DHCP on a Mikrotik

Thanks! Added to FAQ.
SuperUser
Posts: 16,703
Registered: ‎06-23-2010
Kudos: 5274
Solutions: 78

Re: Mikrotik DHCP option 43 How to

Nice. Now if only dhcp option 43 wasn't in hex Man Happy
Member
Posts: 123
Registered: ‎09-27-2008
Kudos: 26
Solutions: 1

Re: Mikrotik DHCP option 43 How to

Has anyone REALLY gotten this to work in Mikrotik?  

My testbed is running 4.5 and it sure doesn't for me.

The Unifis are on 2.3.9 (or whatever the current one is- can't look right now).

 

 

Member
Posts: 114
Registered: ‎10-12-2012
Kudos: 46
Solutions: 5

Re: Mikrotik DHCP option 43 How to

Yes we were using it yesterday with a Unifi Pro.

 

You need to make sure that the hex is correct for the IP address, and that you have added the option to the network in DHCP server.

 

Nick.

 

Nick Shore
LinITX.com - MultiThread Consultants
Get your Ubiquiti gear: http://linitx.com/category/1038
Official UK UBNT Master Distributor
New Member
Posts: 1
Registered: ‎11-15-2012

Re: Mikrotik DHCP option 43 How to

We had remotely connected four locations to our cloud servers where behing pfsense are running four different Ubuntu machines with Unifi controller. On Mikrotik we are using an option 43. It is configured as it is said in the previous posts. For back up we have also configured DNS in the Mikrotik router which points to unifi controller in our cloud.

 

Also be sure that on all Unifi APs there is correct command for informing location of unifi controller: set-inform http://ip-of-controller:8080/inform You can change it if you SSH to Unifi APs.

 

For us it works very well.

Member
Posts: 123
Registered: ‎09-27-2008
Kudos: 26
Solutions: 1

Re: Mikrotik DHCP option 43 How to

Thanks!



Tried 43 several times with no luck, then tried DNS entry as well with same
non-results.

I will double check all entries and then maybe try a different version of
ROS on the MT.



I do 43 all the time with Cisco access points contacting their Wireless Lan
Controllers, and not really unfamiliar with the process- just having trouble
on MT.



And I did set the inform address in the radios correctly.



Just got in a new case of UniFi outdoors to put in 3 Marinas we are redoing
the systems we put in 5 years ago, so I will start with fresh meat.



Ralph
Deleted Account
Posts: 0

Re: Mikrotik DHCP option 43 How to

[ Edited ]

Hi,

you can use this tool for converting IPs to Hex

 

http://www.ipaddresslocation.org/convertip.php

 

 

Format of the option 43 dhcp option:

 

# 01: suboption
# 04: length of the payload (must be 4 bytes)
# 192.168.0.1 in hex = c0a80001

result: option 43 hex 0104c0a80001

 

 

This can be configured on many dhcp servers such as Windows Server DHCP Service, Cisco Routers, Mikrotik, Linksys, etc..

 

cheers

New Member
Posts: 17
Registered: ‎01-16-2011
Kudos: 3

Re: Mikrotik DHCP option 43 How to

The same Option is used to Disable NetBios via DHCP Icon Redface

http://support.microsoft.com/kb/313314

 

Mikrotik Disable Netbios via DHCP

/ip dhcp-server option

add code=43 name=OptionDisableNetBios value=0x010400000002

 

/ip dhcp-server network

add address=192.168.1.0/24 dhcp-option=OptionDisableNetBios dns-server=\
192.168.1.1 gateway=192.168.1.1

Emerging Member
Posts: 88
Registered: ‎03-23-2016
Kudos: 22
Solutions: 3

Re: Mikrotik DHCP option 43 How to

[ Edited ]

rclewis wrote:
After doing a lot of searching, I could not find an easy guide on how to add the option 43 to DHCP on a Mikrotik and get my APs to connect to a remote Controller so I figured I would write one.

My Setup:
Mikrotik 750 (v5.4 os) (Default config)
Unifi 2.2 controller on ubuntu VMWARE guest (Public IP: 192.168.200.10)

1. Convert your public IP to hex. The option 43 value has to be in HEX to work.
192=C0
168=A8
200=C8
10=0A
2. Your option 43 value will be "0x0104" + the HEX of the IP.
So in my example it is: "0x0104C0A8C80A"
3. Open up a new terminal on your Mikrotik or ssh in and type:
/ip dhcp-server option add code=43 name=unifi value=0x0104C0A8C80A
/ip dhcp-server network set 0 dhcp-option=unifi
My router was using the default config so only one network was present ID 0. You could do "/ip dhcp-server network print" to see the list and pick the ID of the network you want to add the option to.
4. Plug in your UAP and it should grab the info and show up on the remote Unifi controller asking to be adopted.

Troubleshooting:
Older UAPs have older firmware. The older firmware does not ask DHCP for option 43. Pulled my hair out for a few hours on this one. The way I found this was by turning on DHCP logging and watched the DHCP Discover. It was not asking for "VendorSpecific" which is option 43. If you have these you have a few options.
1. Upgrade the firmware in the lab by connecting them to a local Controller, adopting them and then "paper-clip" them.
2. Use the discovery tool on them to make them connect.
3. Use DNS. I prefer not to use this method but it does work even on older firmware. In your DHCP server config put in a domain name that you control. Then add a unifi A record pointing to the remote unif controller. Some will say this is easier than Option 43. However if you are doing many different controllers you would have to setup lots of sub-domains and such. And that domain will be default domain name on any hosts connecting on that network.

rclewis,

     Thank you!!!!  I am going to try to get this setup on my clinic sites at work to see if i can stop having to use set-inform!!!

 

Member
Posts: 291
Registered: ‎06-02-2009
Kudos: 72

Re: Mikrotik DHCP option 43 How to

[ Edited ]

To make the task easier. You can place single quotes around the ip address and it will be interpreted as hex.

 

ie.    '192.168.1.1'

Established Member
Posts: 785
Registered: ‎01-02-2009
Kudos: 190

Re: Mikrotik DHCP option 43 How to

[ Edited ]

ip dhcp-server network set 0 dhcp-option=
unifi
no such item

 

- it shows me error

New Member
Posts: 8
Registered: ‎03-30-2016

Re: Mikrotik DHCP option 43 How to

Just incase anyone runs into an issue with this, we just did a few hundred AC AP Pro's and their DHCP request had "ubnt" instead of "unifi" so I had to adjust the code to be as follows

 

/ip dhcp-server option add code=43 name=ubnt value=0x0104C0A8C80A
/ip dhcp-server network set 0 dhcp-option=ubnt

Member
Posts: 155
Registered: ‎04-24-2015
Kudos: 37
Solutions: 4

Re: Mikrotik DHCP option 43 How to

Not a very smart decision to use an ip address instead of a hostname. What if the ip address changes?

New Member
Posts: 8
Registered: ‎03-30-2016

Re: Mikrotik DHCP option 43 How to

This is really only for initial discovery I'd say, you can set the controller to give out a more permanent (ie DNS name) address once they know where to phone home.
Reply