fix: Add IPv6 IMDS support for IPv6-only subnets#70
Merged
dpakpak merged 1 commit intoaws:masterfrom Mar 7, 2026
Merged
Conversation
The IMDS base URL was hardcoded to the IPv4 link-local address (169.254.169.254), causing instance initialization to fail on IPv6-only networks. SSH key injection and metadata retrieval would silently fail since the endpoint was unreachable. Resolve the IMDS endpoint at runtime by trying IPv4 first and falling back to the IPv6 endpoint (fd00:ec2::254). Also support the EC2_METADATA_SERVICE_ENDPOINT_MODE environment variable for explicit override, consistent with the AWS SDK convention.
jahkeup
approved these changes
Mar 6, 2026
|
|
||
| // Neither endpoint confirmed reachable yet — return IPv4 default | ||
| // without caching so we re-probe on the next call. | ||
| return imdsIPv4Base |
Member
There was a problem hiding this comment.
Nice! Thanks for handling the retry loop gracefully 🌮
mjbala
approved these changes
Mar 6, 2026
mattcataws
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
macOS instances launched in IPv6-only subnets fail to initialize. SSH key injection,
metadata retrieval, and all IMDS-dependent operations silently fail because the IMDS
base URL is hardcoded to the IPv4 link-local address (
169.254.169.254), which isunreachable in IPv6-only networks.
Solution
Replace the hardcoded IMDS base URL with runtime endpoint resolution:
169.254.169.254) and IPv6 (fd00:ec2::254)EC2_METADATA_SERVICE_ENDPOINT_MODE(
ipv4|ipv6), consistent with the AWS SDK conventionendpoint is reachable, preserving the existing retry loop behavior
Behavior
Testing
mac2.metalwith IMDS disabled: init retries correctly, recoverswhen IMDS re-enabled, no crash or panic
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.