OPNsense Forum

English Forums => General Discussion => Topic started by: schasj on January 15, 2023, 09:14:14 PM

Title: Reserve same IP for 2 Wi-Fi interfaces
Post by: schasj on January 15, 2023, 09:14:14 PM
I'm still fairly new to OPNsense but I have to give thanks for a fabulous product!

One of the laptops I manage has pretty crappy internal Wi-Fi hardware (it works, but slowly) so I've added a USB Wi-Fi dongle which is WAY better. The trouble is that the dongle may or may not get inserted so I want to have the same IP reserved for both but I've not found a way to do this with OPNsense. Until a few months ago I was using a Linux box for my firewall and I had dnsmasq on it for all things DHCP and it allowed me to specify 2 MACs for the same reserved IP address. Worked like a charm. I have not found any way with OPNsense to achieve the same, not even using the dnsmasq service in lieu of DHCPv4/6 services so I'm stuck with the crappy interface even with the better one plugged in.

I also have a 2nd use case for the same feature and that is any device that may connect through a Wi-Fi extender OR the AP it extends. I don't know that all extenders work the same but the one I have replaces the 1st 3 bytes of the MAC address with its own so, again, I need 2 MACs to get the same IP address.

If there is a way to achieve what I want then please point me to it. If not, please consider this a feature request.

BTW, I have tried to find information on this topic to no avail in this forum or any of the OPNsense docs but I'm almost famous for NOT finding the right search terms so it's no surprise if I've missed it.

Thanks much!
Title: Re: Reserve same IP for 2 Wi-Fi interfaces
Post by: chemlud on January 15, 2023, 09:29:45 PM
..reserve two IPs, for both MACs one each. Define an alias for both IPs (e.g. "Laptop") and use this alias for all rules etc...?
Title: Re: Reserve same IP for 2 Wi-Fi interfaces
Post by: schasj on January 15, 2023, 09:33:04 PM
Thanks for the reply and that might be fine for operations within OPNsense but external apps, Uptime Kuma for example, can't deal with that unless I create 2 separate tests for the target and I find that messy.
Title: Re: Reserve same IP for 2 Wi-Fi interfaces
Post by: cookiemonster on January 15, 2023, 10:09:13 PM
I beleieve dnsmasq can do it but probably need to find a way to put your own config in place, that is without the UI in OPN.
The other option could be to set a static ip on the device itself.
Title: Re: Reserve same IP for 2 Wi-Fi interfaces
Post by: schasj on January 15, 2023, 11:51:44 PM
Thank you, cookiemonster, and I'll see if I can make that work but is there a good reason why OPNsense doesn't let me do what I asked for? I'm not bad with networking but by no means an expert or guru so maybe I'm failing to see why I shouldn't be doing it at all. And if that's the case, shouldn't dnsmasq disallow it?
Title: Re: Reserve same IP for 2 Wi-Fi interfaces
Post by: binaryanomaly on January 16, 2023, 11:13:25 AM
I'm not 100% sure for OPNsense but in Linux you could solve it by creating a bridge spanning both interfaces with one IP. I suppose the same is possible with BSD/OPNsense.
Title: Re: Reserve same IP for 2 Wi-Fi interfaces
Post by: cookiemonster on January 16, 2023, 01:04:59 PM
Quote from: schasj on January 15, 2023, 11:51:44 PM
Thank you, cookiemonster, and I'll see if I can make that work but is there a good reason why OPNsense doesn't let me do what I asked for? I'm not bad with networking but by no means an expert or guru so maybe I'm failing to see why I shouldn't be doing it at all. And if that's the case, shouldn't dnsmasq disallow it?
I don't know actually. From this point it is purely unverified especulation from my part:
Maybe the dhcp in OPN is based on freebsd's dhcpd implementation https://www.freebsd.org/cgi/man.cgi?query=dhcpd.conf&apropos=0&sektion=5&manpath=FreeBSD+13.1-RELEASE+and+Ports&arch=default&format=html (https://www.freebsd.org/cgi/man.cgi?query=dhcpd.conf&apropos=0&sektion=5&manpath=FreeBSD+13.1-RELEASE+and+Ports&arch=default&format=html) and although I haven't looked at the whole documentation, it might show there that there is an expectation of only one hardware identifier can be used. Look in that page at the    The duplicates keyword. That seems to be an option that could be used but maybe it is not in OPN's implementation. And all examples from the docs that I've seen only have one hardware field populated with a single mac address to identify the client.
I imagine OPN will try to stay as close as possible to reference standards.
Now that said, OPN also allows us to use Unbound or dnsmasq as alternatives. I don't think unbound has that ability out of the box, and dnsmasq does, just not in the UI.
Title: Re: Reserve same IP for 2 Wi-Fi interfaces
Post by: schasj on January 19, 2023, 12:30:02 AM
Thanks to all for your time and suggestions.

The "answer" is here https://serverfault.com/questions/578796/how-can-i-set-one-hostname-and-ip-for-multiple-macs-in-dhcpd-isc-dhcpd-4-1-1-p1

However I think it unwise to edit /var/dhcpd/etc/dhcpd.conf outside of the OPNsense GUI so I've manually set the address for both interfaces in NetworkManager on the laptop.

This does NOT solve the related issue of having a device connect through either an AP or an extender to it so I'd still like to see the devs make this possible through the GUI so I'm creating a feature request on github... https://github.com/opnsense/core/issues/6252