2

Steven Black's unified hosts file with base extensions includes the following block in the beginning:

127.0.0.1 localhost
127.0.0.1 localhost.localdomain
127.0.0.1 local
255.255.255.255 broadcasthost
::1 localhost
::1 ip6-localhost
::1 ip6-loopback
fe80::1%lo0 localhost
ff00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
0.0.0.0 0.0.0.0

Which defines three records for localhost (I didn't even know it's valid to include more than one record for the same domain name) and a number of other records I'm not sure should be there (I actually thought a hosts file should be empty unless you have a reason to override something or define a custom domain name).

What does every of these lines mean, in what cases may it be applied and why should it be included in a hosts file?

Giacomo1968
  • 55,001
Ivan
  • 7,513
  • "actually thought a hosts file should be empty" - The default hosts file on Windows only contains localhost (unless of course it is removed). It is perfectly valid to define the same hostname for multiple IP addresses. – Ramhound Feb 19 '19 at 20:45

2 Answers2

3

This is the standard IPv4 localhost we all know and love:

127.0.0.1 localhost

The ::1 is the IPv6 version of 127.0.0.1 so that is what you have here:

::1 localhost

And this is the IPv6 range for local link addresses; this is roughly equivalent to 169.254.*.* in IPv4:

fe80::1%lo0 localhost

As explained on Wikipedia, pay attention to the second paragraph; bold emphasis is mine:

In the Internet Protocol Version 6 (IPv6), the address block fe80::/10 has been reserved for link-local unicast addressing. Of the 64 bits of a link-local addresses' network component, the most significant 10 bits (1111111010) correspond to the IANA-reserved "global routing prefix" for link-local addresses, while the "subnet ID" (the remaining 54 bits) is zero.

Unlike IPv4, IPv6 requires a link-local address on every network interface on which the IPv6 protocol is enabled, even when routable addresses are also assigned. Consequently, IPv6 hosts usually have more than one IPv6 address assigned to each of their IPv6-enabled network interfaces. The link-local address is required for IPv6 sublayer operations of the Neighbor Discovery Protocol, as well as for some other IPv6-based protocols, such as DHCPv6.

Giacomo1968
  • 55,001
  • @Ivan - Instead of submitting additional questions in a comment you should ask a new question or edit your existing question. Just be careful not to invalidate any answers you have received if you edit your existing question. The comment section isn't the place where additional clarification should be provided. – Ramhound Feb 19 '19 at 21:06
  • 1
    @Ivan Added more details from Wikipedia. – Giacomo1968 Feb 19 '19 at 21:12
  • @Ramhound I didn't submit additional questions in the comment above, I've just pointed to the fact the answer doesn't actually answer my question, just the least relevant part of it. – Ivan Feb 19 '19 at 21:14
  • 1
    @Ramhound He is correct. There are no new questions. But the broad question is “What does every of these lines mean, in what cases may it be applied and why should it be included in a hosts file?” Which is something I cam not into answering. I did answer what I could, though. – Giacomo1968 Feb 19 '19 at 21:26
  • Your answer doesn't answer much so I'm not accepting it but I upvote in gratitude for some information I dodn't know about IPv6 and for the attitude to help. – Ivan Feb 19 '19 at 21:46
1

It seems that the following are just taken from the standard hosts file in Ubuntu:

ff00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

And these from MacOS:

255.255.255.255 broadcasthost
fe80::1%lo0 localhost

So my guess is that they just included everything from all types of hosts files.

YouToo
  • 11