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

DHCP scope option 6 (name_server) breaks when using value64 attribute #768

Open
tigattack opened this issue Nov 13, 2023 · 5 comments
Open

Comments

@tigattack
Copy link
Contributor

When applying the name_server option as shown in the example below, it appears to break the data served to DHCP clients.

- tagName: name_server
  value64:
    - "MTAuNTEuMTAuMjA="
    - "MTAuNTIuMTAuMjA="

For example, dhclient successfully retrieves a lease, but warns: domain-name-servers 2 extra bytes at end of array

The result is that dhclient appears to parse this as 49.48.46.53,49.46.49.48,46.50.48.49,48.46.53.50,46.49.48.46 rather than the configured base64 representation of [10.51.10.20,10.52.10.20].

The following configuration works fine, but means I can only pass a single DNS server to the client (unless I'm unaware of some syntax which makes this possible?).

- tagName: name_server
  value: 10.51.10.20

Note: the issue appears to be present regardless of the number of servers specified (tested with 1-3). The only difference is the warning from dhclient notes a differing number of extra bytes at the end of the array.

@BeryJu
Copy link
Owner

BeryJu commented Nov 13, 2023

when using value64 you're responsible for encoding the values correctly yourself

@tigattack
Copy link
Contributor Author

Maybe I'm missing something then, but MTAuNTEuMTAuMjA= and MTAuNTIuMTAuMjA= (from the example config at the top) decode to 10.51.10.20 and 10.52.10.20 as expected.

@july12123
Copy link

july12123 commented Dec 22, 2023

@tigattack The issue is you're converting UTF-8 (Text) to Base64. you need to convert decimal (Number) to Base64. this took me a while to figure out.
image

Red Markings are there for aid

@tigattack
Copy link
Contributor Author

Thank you @july12123, good spot!

@tigattack
Copy link
Contributor Author

Probably a good shout to document this, @BeryJu. I'd happily do it myself, but I'm not sure which options this may be necessary for, so I'll leave it to you to ensure accuracy.

I believe the DHCP options page and docs for the Terraform provider's gravity_dhcp_scope resource will need updating.

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

No branches or pull requests

3 participants