amazonlinux / amazon-linux-2023

Amazon Linux 2023
https://aws.amazon.com/linux/amazon-linux-2023/
Other
531 stars 40 forks source link

[Bug] - AWS DHCP Options set domain-name separated by "032" rather than a space #329

Closed nefnohack closed 1 year ago

nefnohack commented 1 year ago

Describe the bug Use AWS DHCP Options set domain-name separated by "032" rather than a space

To Reproduce

  1. create a dhcp option set with muti domain name like: test1.com test2.com
  2. just associate to VPC and run a new instance as AL2023

Expected behavior the content for /etc/resolv.conf should be(search test1.com test2.com) but it shows below: search test1.com032test2.com

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

nmeyerhans commented 1 year ago

Hi @nefnohack. The issue here is that the VPC DHCP server sends sends the provided list of domains using DHCP option 15, which only supports a single domain name (see RFC 2132 section 3.17). When multiple domain names are provided, they're separated by a space character, which isn't valid in a domain name, so systemd-resolved replaces the space with a decimal encoding of the ascii value.

This has been observed elsewhere as well, and this CoreOS issue provides a good summary including packet captures.

The awscli documentation has the following to say on the topic:

Important : Some Linux operating systems accept multiple domain names separated by spaces. However, Windows and other Linux operating systems treat the value as a single domain, which results in unexpected behavior. If your DHCP options set is associated with a VPC that has instances with multiple operating systems, specify only one domain name.

So for now, our recommendation is to follow that documentation and specify a single domain name in your DHCP option sets.

We've passed on the request to the VPC team to add full support for multiple domain names using DHCP Option 119 ([RFC 3397, section 2) but don't have an estimate about when such support might be available.

nefnohack commented 1 year ago

but other linux system like amazonlinux 2 and redhat donot have this issue

nmeyerhans commented 1 year ago

but other linux system like amazonlinux 2 and redhat donot have this issue

@nefnohack Right, consider it something of an "accidental feature" of these other distros and their DHCP client implementations. The systems where this appears to work aren't doing any validation of the data received from the DHCP server. The end result is that the invalid character is passed through and rendered in the resolv.conf file directly, and happens to be what you want to see. The systems where this experiences problems are validating the data from the DHCP server and correctly identifying that a space character is invalid in a domain and are escaping it.

stewartsmith commented 4 months ago

There's been a section added to our documentation on this: https://docs.aws.amazon.com/linux/al2023/ug/deprecated-al2.html#dhcp-set-domain-name-space