hosts.alpine.tmpl: rearrange the order of short and long hostnames#1084
Conversation
holmanb
left a comment
There was a problem hiding this comment.
Thanks for the PR @dermotbradley.
The FQDN should definitely be second.
I don't think removing the addresses should be an issue. I spot checked alpine 3.11 and edge, both have the following /etc/hosts value:
127.0.1.1 me
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
A grep of the codebase shows that the alpine template is the only one to have those extra addresses and cloud-init doesn't seem to use them. Since they are unnecessary for common usage, I don't have any objections to this.
They used to also be present in the Debian template until they were removed last month by #1021. These entries are only in the Alpine template as, at the time, I thought they were a good idea (I submitted the original Alpine support for cloud-init). |
|
Will merged once CI fix is merged. |
The Alpine /etc/hosts template results in a file where the long form of names (including localhost) come before the short form. This means that when running tools like 'netstat' and 'ss' which convert IP address to names that their output will show 'localhost.localdomain' rather than 'localhost.' This patch swaps the order of the short and long form names so such utils will show the short form name. It also removes several unnecessary IPv6-specific entries.
c59fafe to
199d2fd
Compare
Revert the changes I introduced with canonical#1084, these had the side-effect of causing "hostname" problems. Fixes canonical#4771. Also remove the "::1 {{fqdn}} {{hostname}}" entry as this this being results in strange behaviour with both Busybox "hostname -i" (returns "127.0.0.1", or "127.0.0.1 A.B.C.D" if an additional non-loopback IP entry in /etc/hosts) and Coreutils "hostname -i" (returns "::1" in both situations), commands whereas if the "::1" entry is removed then both Busybox and Coreutils behave the the same fashion returning "127.0.0.1" or "127.0.0.1 A.B.C.D" as appropriate. Also correct hosts.mariner.tmpli file it was not valid (every line was prefixed with "+").
Revert the changes I introduced with canonical#1084, these had the side-effect of causing "hostname" problems. Fixes canonical#4771. Also remove the "::1 {{fqdn}} {{hostname}}" entry as this this being results in strange behaviour with both Busybox "hostname -i" (returns "127.0.0.1", or "127.0.0.1 A.B.C.D" if an additional non-loopback IP entry in /etc/hosts) and Coreutils "hostname -i" (returns "::1" in both situations), commands whereas if the "::1" entry is removed then both Busybox and Coreutils behave the the same fashion returning "127.0.0.1" or "127.0.0.1 A.B.C.D" as appropriate. Also correct hosts.mariner.tmpli file it was not valid (every line was prefixed with "+").
Revert the changes I introduced with #1084, these had the side-effect of causing "hostname" problems. Fixes #4771. Also remove the "::1 {{fqdn}} {{hostname}}" entry as this being present results in strange behaviour with "hostname -i" command: Busybox returns "127.0.0.1", or "127.0.0.1 A.B.C.D" if an additional non-loopback IP entry in /etc/hosts), Coreutils and net-tools both return "::1" in both situations, whereas if the "::1" entry is removed then Busybox, Coreutils, and net-tools "hostname -i" all behave in the same fashion returning "127.0.0.1" or "127.0.0.1 A.B.C.D" as appropriate. Also correct hosts.mariner.tmpli file it was not valid (every line was prefixed with "+"). Fixes GH-4771
Proposed Commit Message
Additional Context
Test Steps
Checklist: