Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dhcpd.inc to Allow Static Mapping to Not Assign Gateway to Client #6425

Closed
wants to merge 1 commit into from

Conversation

NateroniPizza
Copy link

@NateroniPizza NateroniPizza commented Mar 18, 2023

Apologies if there is anything wrong with this pull request - this is the first pull request I've done. Also note that I don't really know PHP (I just have a basic understanding of programming logic, and was googling stuff to figure out the syntax), so please double-check to ensure this doesn't mess anything unintended up.

See issue #6343 , particularly this post for an explanation of what I'm looking to do: #6343 (comment)

The problem's TL;DR:
When creating a DHCP static mapping, the description of "Gateway" states that if you enter "none," it will not assign a gateway to that client (from the description: "Type "none" for no gateway assignment.") However, what this actually does is the same thing as leaving it blank - it omits the value from the client's static mapping in /var/dhcpd/etc/dhcpd.conf, which causes it to reference the pool's "option routers" entry, resulting in it assigning a gateway to the client anyway.

Proposed solution:
When looking through the dhcpd documentation, I did not see a valid value to put for "option routers" in a static mapping that would cause it to override the pool's "option routers" value to just leave it blank. In testing, though, I found that by putting an invalid hostname in for "option routers," it will not assign a hostname to the client pc (as it would need to resolve to an IP, then send that IP for the Gateway field on the client - since it cannot resolve it, it does not send an IP).

The change proposed in this pull request will make it so that if someone enters "none" for the Gateway value in a static mapping, it will add the line "option routers no-gateway-assigned;" to the static mapping's dhcpd.conf entry. As the chances of "no-gateway-assigned" resolving to an IP address in someone's environment would be essentially 0, I can't think of any issues with this. If you would like, this can be changed to any other equally-or-less-likely-to-already-be-used "hostname."

I have briefly (successfully) tested this on both a Windows-based and a Debian-based client, with OPNsense 23.1.3_4-amd64. Note that I did run into a problem with the "option domain-name-servers" being missing from pools at one point, but this appears to only have been when curl'd the dhcpd.inc from the Master branch - when I curl from the 23.1 branch and add just this change in, I do not have any issues.

@fichtner
Copy link
Member

Huh, why not change the validation instead to make this viable input? A magic value for an impossible isc-dhcp configuration is probably going to cause more reports like yours. Also, you can add override files with your required configuration already.

@NateroniPizza
Copy link
Author

NateroniPizza commented Mar 19, 2023

"None" is the input that should cause there to be no gateway assigned to a DHCP client, according to the description of "Gateway" I referenced in the linked issue. Are you proposing removing the "none" value as valid input, and instead change it to "no-gateway-assigned," and that being put into the config like this pull request does? If so, that would work.

For what reason would it cause more reports? The only way I've been able to think of it causing issues would be if someone had "no-gateway-assigned" resolving to an IP, but I know that there's a lot more to any of this than I am aware of.

What override files? Are they accessible via the webGUI? This functionality is supposed to be present in the webGUI, so would like to avoid having to access the command-line to make this type of change.

@fichtner
Copy link
Member

Why remove anything? „none“ seems like either special case or plain host name to me.

Not all things need a GUI. It really depends on the demand and I don’t extrapolate much demand from the general lack of requests in this area.

Again, it was wrong to support none in the overrides, because it doesn’t work in isc-dhcp if you already have a router assigned globally.

Cheers,
Franco

@kulikov-a
Copy link
Member

@NateroniPizza
Hi
have you tested setting the static lease gateway address to the lease address?
maybe this will do the trick without "trick"?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants