Setting dnsmasq for dhcp with static leases

I am just coming from DD-WRT, with which I had configured easily dhcp and static leases via dnsmasq.
I am very excited discovering openWRT which seem to be more scalable, but I cannot just use a copy / pasted of my previous settings.
I have read https://openwrt.org/docs/guide-user/base-system/dhcp.dnsmasq but I am still stuck.

I set static leases in the web ui (sorry LuCI), in http://x.x.x.x/cgi-bin/luci/admin/network/dhcp# and I can find the settings in dsnmasq.conf, but they are not effective, even if dnsmasq is restarted, I do not understand why.

Even I do not understand why the syntax is not the same as I used with dd-wrt.
For example, my dnsmasq settings in the ddwrt web ui were :

===========

#Additional Dnsmasq Options

===========

#Disable NetBIOS over TCP/IP for microsoft clients with Dnsmasq
dhcp-option=vendor:MSFT,1,2i
dhcp-option=43,01:04:00:00:00:02

domain=tom
#if you want the router to append your domain on DNS request, put "expand-hosts" into the DNSMasq other options
expand-hosts
dhcp-range=192.168.1.116,192.168.1.130,255.255.255.0,24h

scanners 235-240

dhcp-host=FF:FF:FF:FF:FF:FF,192.168.1.235,canonscan,infinite

printers 230-235

dhcp-host=FF:FF:FF:FF:FF:28,192.168.1.232,brothercouleur,infinite
dhcp-host=FF:FF:FF:FF:FF:23,192.168.1.231,laserjet,infinite
dhcp-host=FF:FF:FF:FF:FF:8C,192.168.1.230,brother,infinite

nas 220-230

dhcp-host=FF:FF:FF:FF:FF:BC,192.168.1.225,nassalon4,infinite
dhcp-host=FF:FF:FF:FF:FF:BB,192.168.1.224,nassalon3,infinite
dhcp-host=FF:FF:FF:FF:FF:BA,192.168.1.223,nassalon2,infinite
dhcp-host=FF:FF:FF:FF:FF:B9,192.168.1.222,nassalon1,infinite
dhcp-host=FF:FF:FF:FF:FF:FF,192.168.1.221,nas1,infinite
dhcp-host=FF:FF:FF:FF:FF:B0,192.168.1.220,nas2,infinite

I have read that someone used /etc/ethers to specify satic addresses.
I see that some of my hosts use ip v6, and I don't know how it can interfere ...

I just need dnsmaq to set an ip range for dynamic DHCP, and static leases per mac address ... and it seem to be more complex that my previous experience. Any help or clues will be appréciated.

Have you really red that guide? Just tap "set static" in web UI, then edit coorect IP into config/ file and on next refresh client will go to its expected IP.

If you can write a little script, you can add the IP reservations to /etc/config/dhcp. The entries look like this:

config host
        option name 'your-host-name'
        option dns '1'  # Make sure dnsmasq serves this name
        option mac '00:05:5D:01:02:03'
        option ip '10.1.1.20'  # Pick an IP from your subnet, can be inside or outside the DHCP range
        option duid '0003000100155d01a023'  # For IPv6 device id
        option hostid '20'  #  The IPv6 suffix for ULA and GUAs

You can restart dnsmasq as much as you like, that won't magically tell the clients to obtain a fresh DHCP lease, that only happens when their lease times out (typically after 6 hours) or if you restart the client(s) in question.

There is a tiny catch, pre-existing active leases take precedence, so you might want to restart the router after configuring your DHCP settings as well (or do more targeted surgery, as an advanced user).

Thank you for your replies to help me.

To brada4 :
I have read the guide, here is a screenshot to prove it, but maybe I have made a mistake ?

To efahl :
I am surprised to have to write 4 lines per hosts, where one line was enought before, because I have several hosts to write (even if it is done one time for all) ... I must learn to wrtie scripts ... yes ... .
The problem is that I have tested for a few machines, and it do not work. The host with de ... : AB:8B mac adress, had an ip given in the DHCP range, instead of the configured lease, despite I can see the result of the web UI config in /etc/config/dhcp :

(second image not authorized see my next post)

To slh :
I wrote errors and I was imprecise, I can see settings in /etc/config/dhcp, not in dnsmasq.conf and I have made several test by reseting wifi client configuration, and restarting client, try with a never connected client ... impossible to set a static lease.

I am used of the previous ddwrt dnsmasq function who work like a charm after restarting or disconnect/connect clients Wireless lan interfaces ... I am feeling that I am missing something obvious here ... I am ready to fine surgery, but where must I operate ?

Like we say in France, devil hide in details ...

... despite I can see the result of the web UI config in /etc/config/dhcp :

I finded it !
I had set a "Tag" in Edit static lease "Tag" line.

I misunderstand the use of the "Tag" and "Match Tag" functions for the moment.
I have deleted previous "Tag", and disconnect / reconnect clients ... it is working like a charm ...

Now ... I need to set up all my Lan and Wireless lan machines ...

1 Like

show this:

https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#client_classifying_and_individual_options

ps: Please do not take screenshots of your configurations in the future. Copy and paste the text using the "</>" function button. (Hiding any passwords and MAC addresses will make it easier to read)

Please use the "Preformatted text </>" button for logs, scripts, configs and general console output (red circle; this works best in the 'Markdown' composer view in the blue oval):

Screenshot 2025-10-20 at 8.14.14 PM

2 Likes