Skip to content

dhcp offer ip by client id in dhcpv4 - #6110

Open
nmreadelf wants to merge 1 commit into
AdguardTeam:masterfrom
nmreadelf:master
Open

dhcp offer ip by client id in dhcpv4#6110
nmreadelf wants to merge 1 commit into
AdguardTeam:masterfrom
nmreadelf:master

Conversation

@nmreadelf

@nmreadelf nmreadelf commented Aug 17, 2023

Copy link
Copy Markdown

I have configured a virtual machine that utilizes the host network on my physical machine. Upon examination, I discovered that the AdGuard Home server being hosted offers IP addresses based on the MAC address of the physical host machine rather than the virtual machine itself. Specifically, the actual MAC address of the virtual machine is present in the client-id field of DHCP requests. For proper functionality, the DHCP server should be offering IP addresses based on the client-id field, which contains the MAC address of the virtual machine. This would allow the DHCP server to correctly identify the virtual machine and provide it an IP address accordingly. The current behavior indicates a misconfiguration, where the DHCP server is assigning IP addresses using the physical host's MAC address instead of the virtual machine client's MAC address contained in the DHCP request.

resolve #6135

@nmreadelf nmreadelf changed the title Judge client id in dhcpv4 dhcp offer ip by client id in dhcpv4 Aug 17, 2023
@nmreadelf
nmreadelf marked this pull request as draft August 17, 2023 03:22
@nmreadelf
nmreadelf marked this pull request as ready for review August 17, 2023 08:53
@nmreadelf
nmreadelf marked this pull request as draft August 17, 2023 09:59
@nmreadelf
nmreadelf marked this pull request as ready for review August 17, 2023 10:14
@ainar-g
ainar-g requested a review from EugeneOne1 August 21, 2023 14:19
@ainar-g ainar-g added this to the v0.107.37 milestone Aug 21, 2023
@EugeneOne1

EugeneOne1 commented Aug 23, 2023

Copy link
Copy Markdown
Member

Hi @nmreadelf, sorry for the late reply and thanks for the contribution.

As far as I know, RFC-4361 Section 6.1, which updates the referenced RFC-2132, actually forbids using the hardware address in option 61 alone. However, a cursory internet search indicated that this feature may be somewhat useful, so could you please file a "feature request" issue so that we can see if it's actually the case?

@EugeneOne1 EugeneOne1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment.

@nmreadelf

Copy link
Copy Markdown
Author

Hi @nmreadelf, sorry for the late reply and thanks for the contribution.

As far as I'm know, RFC-4361 Section 6.1, which updates the referenced RFC-2132, actually forbids using the hardware address in option 61 alone. However, a cursory internet search indicated that this feature may be somewhat useful, so could you please file a "feature request" issue so that we can see if it's actually the case?

relate #6135

@nmreadelf

nmreadelf commented Oct 7, 2023

Copy link
Copy Markdown
Author

@EugeneOne1 @ainar-g hello, i resolve merge conflicts, can you make approve again?

@nmreadelf

Copy link
Copy Markdown
Author

@EugeneOne1 @ainar-g hello, Could you please assist in merging this pull request? It has been open for close to a year.

@EugeneOne1 EugeneOne1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmreadelf, good afternoon and apologies for late review. The reactions to the issue proposing this change seem to not have demonstrated the need for it. In addition, you never responded to our concerns about the standard's recommendations. So, we are not ready to merge this change.
You can always keep this feature in your personal fork of AdGuard Home.

@Sil3ntVip3r

Copy link
Copy Markdown

I rechecked exact head 9ba9ba73 on the current Go toolchain. It no longer
compiles:

go test -race -count=1 ./internal/dhcpd
internal/dhcpd/v4_unix.go:25:2: slices redeclared in this block
internal/dhcpd/v4_unix.go:25:2: "golang.org/x/exp/slices" imported and not used
FAIL github.com/AdguardTeam/AdGuardHome/internal/dhcpd [build failed]

The branch imports both the standard-library slices package and
golang.org/x/exp/slices; git diff --check itself is clean.

More importantly, resolving that compile error would not make the
implementation safe to merge. The patch treats any seven-byte option 61 with
a nonzero type as an Ethernet MAC and overwrites req.ClientHWAddr. RFC 4361
section 6.1 defines the modern type-255 IAID+DUID form, while section 6.3
requires a conforming server to use option 61 as the client identity when
supplied. A future implementation should preserve option 61 as an opaque
lease identity (with explicit legacy type handling) instead of reinterpreting
it as chaddr.

The linked feature request #6135 has received no additional use-case
discussion since 2023, and the maintainer already concluded that the demand
and standards questions do not justify merging this approach. I therefore
recommend closing this conflicting PR. I did not run the full suite or
packet-level runtime tests, and I did not prepare a current-master port,
because the exact target package cannot build and the product direction
remains rejected.

@nmreadelf

Copy link
Copy Markdown
Author

I rechecked exact head 9ba9ba73 on the current Go toolchain. It no longer compiles:

go test -race -count=1 ./internal/dhcpd
internal/dhcpd/v4_unix.go:25:2: slices redeclared in this block
internal/dhcpd/v4_unix.go:25:2: "golang.org/x/exp/slices" imported and not used
FAIL github.com/AdguardTeam/AdGuardHome/internal/dhcpd [build failed]

The branch imports both the standard-library slices package and golang.org/x/exp/slices; git diff --check itself is clean.

More importantly, resolving that compile error would not make the implementation safe to merge. The patch treats any seven-byte option 61 with a nonzero type as an Ethernet MAC and overwrites req.ClientHWAddr. RFC 4361 section 6.1 defines the modern type-255 IAID+DUID form, while section 6.3 requires a conforming server to use option 61 as the client identity when supplied. A future implementation should preserve option 61 as an opaque lease identity (with explicit legacy type handling) instead of reinterpreting it as chaddr.

The linked feature request #6135 has received no additional use-case discussion since 2023, and the maintainer already concluded that the demand and standards questions do not justify merging this approach. I therefore recommend closing this conflicting PR. I did not run the full suite or packet-level runtime tests, and I did not prepare a current-master port, because the exact target package cannot build and the product direction remains rejected.

compile problem fixed

@nmreadelf
nmreadelf force-pushed the master branch 2 times, most recently from fc5fa4a to 9a33c73 Compare August 5, 2026 12:34

@Sil3ntVip3r Sil3ntVip3r left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head ced76bb47b4499c374131a48c3b2eb411696044d. The import/compile repair is good, but this still is not ready to merge.

  1. The current implementation does not solve the scenario in the PR body. clientMAC uses option 61 only when chaddr is nil or all-zero, and the new valid_chaddr_is_preferred test makes that explicit. With a nonzero physical-host chaddr and a legacy type-1 option-61 containing the VM MAC, it still returns the physical-host MAC. All of handleDiscover, request handling, and release lookup then use that value, so the VM cannot receive a separate lease. I verified this with a focused disposable test of exactly that packet shape. Please either implement an explicit, end-to-end client-identity policy (including lease lookup/storage and reply-delivery implications) with a regression test for nonzero chaddr plus option 61, or close this PR as it cannot satisfy its stated use case. The current type-255 protection is good, but this fallback is not RFC-4361 client-identity support.

  2. make go-check currently fails before tests because gofumpt requires a blank line before TestV4Server_clientMAC in internal/dhcpd/v4_unix_internal_test.go. Please fix that and rerun the gate.

Focused go test -race -count=1 ./internal/dhcpd and go vet ./internal/dhcpd pass on this head; the full gate fails only at the formatter described above.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allocate IP address based on the MAC address in the client identifier.

4 participants