-
Notifications
You must be signed in to change notification settings - Fork 519
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
support non-standard DHCP Option 15 in EC2 #3416
support non-standard DHCP Option 15 in EC2 #3416
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the very edge of my understanding of C but it makes sense. Nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a clean way to deal with the ambiguity resulting from multiple domains being specified. ✔️
packages/systemd/9013-sd-dhcp-lease-parse-multiple-domains-in-option-15.patch
Outdated
Show resolved
Hide resolved
EC2 VPCs have an associated DHCP option set which can include a field for domain name. This data is passed to instances via DHCP Option 15 in the lease. For Linux distros not using systemd-networkd, such as older versions of Amazon Linux and older variants of Bottlerocket, the data from the option is written into `/etc/resolv.conf` as the "search" field, with essentially no validation or normalization. Separating domain names with a space character in the VPC's DHCP option set "just works" and causes host lookups to use all of the domains in the DNS search path. However, systemd-networkd normalizes the Option 15 payload, replacing the space character with "032". While this results in a valid domain name, it doesn't match any of the ones that are present in the VPC's DHCP option set, and breaks this accidentally useful but non-standard functionality. Ideally, any EC2 VPC DHCP option sets relying on this behavior would be modified to set only one domain name. Unfortunately, DHCP option sets are a VPC-wide setting, so the change can't be restricted to a subset of instances without creating a new VPC for those instances. Alternatively, EC2 could detect when space-separated domain names are present in the DHCP option set, then use DHCP Option 15 for the first domain name and DHCP Option 119 for the full list. In the meantime, carry a patch to cause systemd-networkd to do that instead: treat Option 15 as a potentially space-separated list of domain names; use the first such domain as the domain name; and use the full list for search domains unless Option 119 is provided. Signed-off-by: Ben Cressey <[email protected]>
cd147b1
to
b7d0b8f
Compare
Still looking good! |
Issue number:
Fixes #3412
Description of changes:
EC2 VPCs have an associated DHCP option set which can include a field for domain name. This data is passed to instances via DHCP Option 15 in the lease.
For Linux distros not using systemd-networkd, such as older versions of Amazon Linux and older variants of Bottlerocket, the data from the option is written into
/etc/resolv.conf
as the "search" field, with essentially no validation or normalization. Separating domain names with a space character in the VPC's DHCP option set "just works" and causes host lookups to use all of the domains in the DNS search path.However, systemd-networkd normalizes the Option 15 payload, replacing the space character with "032". While this results in a valid domain name, it doesn't match any of the ones that are present in the VPC's DHCP option set, and breaks this accidentally useful but non-standard functionality.
Ideally, any EC2 VPC DHCP option sets relying on this behavior would be modified to set only one domain name. Unfortunately, DHCP option sets are a VPC-wide setting, so the change can't be restricted to a subset of instances without creating a new VPC for those instances.
Alternatively, EC2 could detect when space-separated domain names are present in the DHCP option set, then use DHCP Option 15 for the first domain name and DHCP Option 119 for the full list.
In the meantime, carry a patch to cause systemd-networkd to do that instead: treat Option 15 as a potentially space-separated list of domain names; use the first such domain as the domain name; and use the full list for search domains unless Option 119 is provided.
Testing done:
No domain name in option set:
One domain name in option set:
Two domain names in option set:
253 characters' worth of domain names in option set:
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.