OPNsense Forum

Archive => 20.7 Legacy Series => Topic started by: jmcgee on November 16, 2020, 10:55:42 PM

Title: Static DHCP
Post by: jmcgee on November 16, 2020, 10:55:42 PM
I recently installed Opnsense on a Qotom machine.  It installed fine and is working.   I want to assign MAC addresses of devices to static DHCP.  I have google, read docs, searched forum  Where do I do this;
I am running:
OPNsense 20.7.4-amd64
FreeBSD 12.1-RELEASE-p10-HBSD
OpenSSL 1.1.1h 22 Sep 2020

It's a fairly standard install, 1 WAN port, 2 LAN ports, no vlan.
Title: Re: Static DHCP
Post by: muchacha_grande on November 17, 2020, 12:39:29 AM
Hi, you will find this on Services > DHCPv4 or 6 > [INTERFACE NAME]
You have to turn on DHCP service and fill the automatic address assignment range.
Then, at the bottom, you'll find a list to add MAC-IP mappings.
Title: Re: Static DHCP
Post by: jmcgee on November 17, 2020, 01:56:44 AM
Perfect. Found it.  Question.
I assumed DHCP static mapping would map MAC addresses to IP number within the DHCP range.
I have told DHCP to use range 192.168.1.5 to 192.168.1.100.

If I try to use address 192.168.1.16 it says
The following input errors were detected:
    The IP address must not be within the DHCP range for this interface.

I can give it 192.168.1.108 and it works.
Title: Re: Static DHCP
Post by: TomK on November 17, 2020, 02:23:57 AM
Your static mappings need to be outside of the range chosen for auto mapping.
Title: Re: Static DHCP
Post by: Ricardo on November 17, 2020, 05:04:46 PM
Quote from: TomK on November 17, 2020, 02:23:57 AM
Your static mappings need to be outside of the range chosen for auto mapping.

Yeah, I would say there are at least 2 approaches:

1 is that I got used to in the past 10+ years is that you have a DHCP range. If you want, you can  enable some DHCP clients to be "reserved". What that means, you make the IP address assignment bound to the MAC address. Now thats what opnsense NOT does.

The other option, what Opnsense does, that you create a generic DHCP range, anything that gets served from that range will be dynamic. If you want a DHCP client to be static, you have to create a MAC address-IP address mapping outside of that range.
Title: Re: Static DHCP
Post by: Gauss23 on November 17, 2020, 05:45:19 PM
I have an open PR: https://github.com/opnsense/core/pull/4447

This limitation is from the past. It's not needed anymore. I hope in one of the next releases my PR will be merged.