OPNsense Forum

English Forums => General Discussion => Topic started by: echoxxzz on February 11, 2026, 04:31:40 AM

Title: How to use DHCP options in Dnsmasq?
Post by: echoxxzz on February 11, 2026, 04:31:40 AM
The DHCP options settings interface in Dnsmasq is a tad confusing.

You can select both a DHCP4 option and a DHCP6 option, but there is only one place to set a value. So which option does the value apply to?

For example, if I want to set the DNS servers, I would pick Option4 dns-server[6] and Option6 dns-server[23], but what value do I put? Is it the IPv4 DNS server than a colon and then the IPv6 DNS-servers?

If, on the other hand, you should only pick one Option type at a time, someone should redesign the interface to make this a little more intuitive.
Title: Re: How to use DHCP options in Dnsmasq?
Post by: Mpegger on February 11, 2026, 04:53:34 AM
Its one or the other,IPv4 -or- IPv6. You have to create individual IPv4 options, and seperate IPv6 options.

For your dns-server [6] option, that would only apply to IPv4, and the ip address you enter would of course only be IPv4 ip, seperated by a comma if entering multiple addresses.
Title: Re: How to use DHCP options in Dnsmasq?
Post by: OPNenthu on February 11, 2026, 05:10:49 AM
Someone (maybe @Monviech?) can speak to this authoritatively for OPNsense.  My interpretation is in line with @Mpegger.

I think evidence for this is in the Dnsmasq manual (https://dnsmasq.org/docs/dnsmasq-man.html) if looking at the syntax for --dhcp-option:

Quote-O, --dhcp-option=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>|option6:<opt>|option6:<opt-name>],[<value>[,<value>]]

They use OR (|) to indicate that you can pass either <option> or <option6>, but not both.

--

EDIT: actually, it looks like the OPNsense UI is explicit about it (screenshot) when you try to save :P

Title: Re: How to use DHCP options in Dnsmasq?
Post by: nero355 on February 11, 2026, 04:21:45 PM
Have a look at this DNSmasqd examples config file : https://github.com/imp/dnsmasq/blob/master/dnsmasq.conf.example

And start at line 328 for DHCP Option related configuration.

As you can see each option needs to be put on a new line so you can't have multiple options on the same line !!
You can however have multiple values for the same option on the same line.

My guess is that the OPNsense webGUI tries to simulate that logic too, but maybe not the way you are expecting it to do :)
Title: Re: How to use DHCP options in Dnsmasq?
Post by: Monviech (Cedrik) on February 11, 2026, 04:42:50 PM
No the GUI just didn't want to have two seperate input masks for IPv4 and IPv6, thats why there is input validation taking care of it.

Our input validation file is very large, it's unlikely to create a wrong configuration.

Since Dnsmasq is not as cleanly separated in concerns the GUI reflects that too (some like it, some dislike it).

https://github.com/opnsense/core/blob/8a52f03b37542ff6978afc4a5edef6428b9563ef/src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php#L362