Skip to content

hostname config only changes /etc/hostname, but misses /etc/hosts #4

@davidje13

Description

@davidje13

After running cloud-init with a user-data containing:

hostname: pi5

I find that every time I run sudo (for any command), it prints a warning:

$ sudo true
sudo: unable to resolve host pi5: Name or service not known

/etc/hostname is set correctly:

pi5

but /etc/hosts has the default value:

127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters

127.0.1.1		raspberrypi

Manually running sudo raspi-config nonint do_hostname pi5 sets /etc/hosts correctly, fixing the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions