How to set Option 43 in DNSMasq (for Ubiquiti/Unifi devices)

This one stumped me, so I figured I’d write down how I did it.

What is DHCP Option 43?

DHCP Option 43, also known as "Vendor-specific option", is a DHCP option that allows the DHCP server to send custom or vendor-specific data to devices that match a given vendor class. The option contains encapsulated vendor-specific option.

It is defined in RFC2132#8.2, which specifies the format for the option.

Ubiquiti Option 43

Ubiquiti (unifi devices) uses option 43 (sub-option 1) to send the IP address of the unifi controller to devices to enable L3 adoption. If you use an unifi device as your DHCP server, it’ll be automatically configured for you, otherwise, you have to configure it yourself.

Within DNSMasq, the option is set in the configuration file as follows:

dhcp-option=vendor:ubnt,1,ip.address.goes.here

Let’s break it down.

dhcp-option indicates to DNSMasq that we want to define a new DHCP option. You can define many DHCP options, with later ones overwriting earlier ones.

Option 43 is also called "Vendor-specific encapsulated" option, because it itself contains any number of encapsulated options that have a vendor-specific meaning.

The vendor:ubnt portion indicates that this option should be included when the DHCP request matches the ubnt vendor class. This class (ubnt) is sent by ubiquiti devices using option 60, so you don’t have to do anything to set that up.

The 1 portion indicates that we’re specifying the valid for the vendor-specific suboption #1. The last portion is the IP address of the Unifi controller. Ubiquiti decided of this scheme, we just need to match it.

That’s it. Ubiquiti devices (and most devides) will indicate that they request option 43 by specifying option 60 in the request, so they’ll receive this information. If you decide that you want to force the DHCP response to have option 43 even when the device doesn’t request it, simply change dhcp-option to dhcp-option-force.

If you want to send a vendor-specific encapsulated field to all clients that request vendor-specific encapsulated options, regardless of the vendor class, simply omit the value of the vendor class in your dhcp option: vendor:,1,ip.address.goes.here.