- Más nuevo
- Más votos
- Más comentarios
I was able to resolve this issue with help from ChatGPT. The issue was the way I was using Ansible to template the hostname as a second entry for the loopback interface, so even though the correct hostname was specified in both /etc/hosts
and /etc/hostname
, hostname -f
(used internally by SSM Agent) was still returning localhost
as the first matching entry. The solution was to put the hostname on the entry for 127.0.1.1
instead, which causes hostname -f
to return the correct output. This works because IETF defines the loopback address as 127.0.0.0/8
. Working /etc/hosts
file:
127.0.0.1 localhost
127.0.1.1 dev-backend
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
A few more interesting differences in the /etc/hosts
files on these nodes:
The single on-premises host that is reporting the hostname correctly:
pi@nucleus-v3-7:~$ cat /etc/hosts
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 nucleus-v3-7 pi
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
The other on-premises host that reports localhost
:
pi@pi-1:~$ cat /etc/hosts
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 pi pi
127.0.0.1 localhost pi-1
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
And an EC2 host:
ubuntu@dev-backend:~$ cat /etc/hosts
127.0.0.1 localhost dev-backend
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Contenido relevante
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace 2 años