With
aws ssm get-parameters-by-path --path /aws/service/debian/release/bookworm/ --recursive
I was able to list all official Debian 12 AMIs and I am only interested in amd64 AMIs.
My VPC and subnet have enableDnsSupport
set to true.
All my tests are made in the same VPC, same subnet and same security group.
The only thing that changes is the AMIs (all of them from the official Debian account).
I don’t do any config in the EC2 instances. I just start then and try to run a sudo command (ex: sudo ls)
With the following AMIs : ami-087da76081e7685da, ami-058a645884552df66 and ami-07254a4b88b1dc88d I can sudo without any issues
$ sudo ls => my current folder is empty
$ hostname -f
ip-10-0-3-203
if I run an sudo apt update && sudo apt full-upgrade -y
, everything looks great and I have the same result with sudo ls and hostname -f
With the latest AMI (ami-04d8e65bd49d048bd) when I run any sudo command (ex : sudo ls
) I am getting the following error
$ sudo ls
sudo: unable to resolve host ip-10-0-3-101: Name or service not known
$ hostname -f
hostname: Name or service not known
cat /etc/hosts on all ami have the same pattern
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Same for cat /etc/hostname
ip-10-0-3-203
How could I fix the issues on instances using the latest Debian 12 ami (ami-04d8e65bd49d048bd) ?
PS: I have also opened a ticket on the https://salsa.debian.org/cloud-team/debian-cloud-images/-/issues/84 and if someone could help me figuring out what the root cause of the issue is, I would be glad to report it to the Debian Salsa too.
2
Answers
I have opened a ticket at https://salsa.debian.org/cloud-team/debian-cloud-images/-/issues/84 and the ticket has been addressed : A new AMI that fixes the issue has been published (ami-088a888e9b38f5006 for eu-west-3, cf. https://wiki.debian.org/Cloud/AmazonEC2Image/Bookworm for other regions).
Noah Meyerhans explained : "We had originally launched the Debian 12 cloud images with libnss-resolve packages installed, which caused systemd-resolved to handle DNS resolution and caching of results. However, there have been a number of issues reported with this configuration (e.g. https://github.com/systemd/systemd/issues/29069). So we removed libnss-resolved, but in doing so neglected to replace it with libnss-myhostname, which is needed to synthesize results for local hostnames. The current release fixes that oversight."
To test your situation, I did the following:
eu-west-3
(Paris) regionami-04d8e65bd49d048bd
Debian 12 (20240415-1718)sudo -i
I received a similar response:
The reference to
ip-172-31-39-60
is significant because the EC2 instance was assigned a private IP address of172.31.39.60
and a DNS name ofip-172-31-39-60.eu-west-3.compute.internal
.This suggests that the instance was attempting to resolve a partial domain name, but the default domain name was not
eu-west-3.compute.internal
.I then added an entry to
/etc/hosts
:This then allowed
sudo -i
to work:Summary
I’m not sure what is causing the problem, but adding an entry to
/etc/hosts
is a simple workaround for the problem.