aboutsummaryrefslogtreecommitdiffstats
path: root/community/cloud-init/02-hosts-template-fix.patch
blob: d6e04e15a00307dc71625c73d4ac74cbedbc848e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From: Dermot Bradley <dermot_bradley@yahoo.com>
Date: Sat, 21 Nov 2020 16:52 +0000
Subject: [PATCH] cloud-init: Change order of entries in /etc/hosts

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.

---

diff -aur a/templates/hosts.alpine.tmpl b/templates/hosts.alpine.tmpl
--- a/templates/hosts.alpine.tmpl
+++ b/templates/hosts.alpine.tmpl
@@ -13,13 +13,13 @@
 #     /etc/cloud/cloud.cfg or cloud-config from user-data
 #
 # The following lines are desirable for IPv4 capable hosts
-127.0.1.1 {{fqdn}} {{hostname}}
-127.0.0.1 localhost.localdomain localhost
-127.0.0.1 localhost4.localdomain4 localhost4
+127.0.1.1 {{hostname}} {{fqdn}}
+127.0.0.1 localhost localhost.localdomain
+127.0.0.1 localhost4 localhost4.localdomain4
 
 # The following lines are desirable for IPv6 capable hosts
-::1 {{fqdn}} {{hostname}}
-::1 localhost6.localdomain6 localhost6
+::1 {{hostname}} {{fqdn}}
+::1 localhost6 localhost6.localdomain6
 
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix