OPNsense Forum

Archive => 21.7 Legacy Series => Topic started by: Miwer on December 22, 2021, 12:29:17 AM

Title: How to add custom options in DHCP pools?
Post by: Miwer on December 22, 2021, 12:29:17 AM
Hi,

I really hope someone can help me on how to insert custom options in dhcpd.conf file.

Basically I have a main pool, with the option "Deny unknown clients" checked on, and an additional pool in the same subnet, with this checked off.

I also have registered a client MAC address, to make it a "known" client.

The problem I am facing is, that I need to have an "allow unknown-clients" in the additional pool, in order to ONLY assign addresses from this pool to unknown clients, and not allow to assign to known clients, and there is no option in the GUI to do this.

Normally it would work fine with the current setup, but not if the client have previously been assigned an address from the second pool. In that case, the client will request the previous address, and dhcp server will just ACK it, instead of NAK, so the client can discover and be offered an address from the correct pool instead.

So - here is roughly what my dhcpd.conf file looks like, and what I wish to achieve.


subnet 192.168.10.0 netmask 255.255.255.0 {
  pool {
    deny unknown-clients;
    range 192.168.10.128 192.168.10.191;
  }

  pool {
    allow unknown-clients;    <-- I wish to insert this line
    range 192.168.10.64 192.168.10.127;
  }

  option routers 192.168.10.1;
  option domain-name-servers 192.168.10.1;

}

host s_opt3_1 {
  hardware ethernet aa:bb:cc:dd:ee:ff;
}


Without the allow line above, the client is still allowed to request a previous assigned address from the wrong pool, even though I want it to get an address from the first pool.

2021-12-21T23:56:46 dhcpd[24062] DHCPACK on 192.168.10.71 to aa:bb:cc:dd:ee:ff (foobar) via bridge0
2021-12-21T23:56:46 dhcpd[24062] DHCPREQUEST for 192.168.10.71 from aa:bb:cc:dd:ee:ff via bridge0


If I can add the allow line, the dhcp server would NAK the request (since it's a known client, and dhcp would only allow unknown clients in this pool).

I have this setup working on another dhcp server, and it's also shown as an example in this man file under the section "Address pools" - https://www.math-linux.com/man/man5/dhcpd.conf.5.html

So how can I achieve this?
I cannot edit the file directly, since any changes is overwritten on dhcpd restart.

Thanks to anyone with the solution. ;)
Title: Re: How to add custom options in DHCP pools?
Post by: Miwer on January 08, 2022, 03:49:53 PM
Happy new year to everyone. :)
I'm still hoping anyone maybe have an idea how to add custom options to DHCP config file.