In OPNsense 26.1.2, ISC DHCPv4 is declared legacy. So I should switch to a different DHCP server.
I have decided to use dnsmasq for the time being. However, my OPNsense is NOT operated as a DNS server and is not intended to be in the near future. Dnsmasq must therefore be configured as a pure DHCP server.
I disable the DNS server by setting the listener port to 0.
For dynamic IP address assignment, I configure a DHCP range for each subnet that listens on an interface. For the corresponding default gateway and DNS server, I configure DNS options that are also mapped to an interface.
So far, so good, I think. What is less clear to me is how I now assign MAC addresses to IP addresses statically. Especially when a device can communicate via different interfaces and should be assigned different IP addresses for the same MAC address.
Am I right in thinking that I have to do this under Hosts? And that I have to make several entries with the same MAC address? One per IP address? What confuses me is that I can't define an interface there.
In short: How can I assign different static IP addresses to a device with a MAC address in dnsmasq depending on the OPNsense interface?
If I understand what you want, you can just add multiple Host overrides.
Per the Dnsmasq manual (https://dnsmasq.org/docs/dnsmasq-man.html):
QuoteMore than one --dhcp-host can be associated (by name, hardware address or UID) with a host. Which one is used (and therefore which address is allocated by DHCP and appears in the DNS) depends on the subnet on which the host last obtained a DHCP lease: the --dhcp-host with an address within the subnet is used.
You would use the same MAC in each Host override. Just change the IP address and Dnsmasq will automatically sort out which one to use depending on the subnets you have defined (in DHCP ranges).
I do the same for my main PC which is used as both a normal client and a management station on occasion and I want this PC to get a .100 address on any of the connected subnets / VLANs. In my case I also specify the domain associated with the range though I'm not sure if that's strictly necessary.
multiple-Hosts-for-MAC.png
Thank you very much for your quick and clear answer. You understood correctly.
I will now start migrating the DHCP server. Thanks to Snapshot, I have a fallback.