What's the use for the special ipv6 addresses in /etc/hosts?
Solution 1
According to RFC 4291, Section 2.7: Multicast Addresses, the first 8 bits (FF
in FF0X
) at the beginning of identifies the address as a muticast address.
The flags, the next 4 bits, (the first 0
in FF0X
) in the question indicate:
... a permanently-assigned ("well-known") multicast address, assigned by the Internet Assigned Numbers Authority (IANA).
The next 4 bits, (the last hex value 0
or 2
in FF00
or FF02
) define the scope:
0 reserved
[...]
2 Link-Local scope
[...]
The reserved scope is reserved for future use.
The Link-local scope means, that packages within that scope will never be routed and therefore cannot leave the subnet.
So the addesses mean he following:
-
::1:
This is the loopback address, whose IPv4-equivalent is127.0.0.1
. -
fe00::0
: Can be compared to the Class E address space in IPv4, therefore it's in the reserved scope; reserved for future use. -
ff02::1
: The group of all IPv6 nodes (including the routers) in the Link-local scope, whose IPv4-equivalent is224.0.0.1
. -
ff02::2
: The group of all IPv6 routers in the Link-local scope, whose IPv4-equivalent is224.0.0.2
. -
ff02::3
: This exists no longer an is unassigned at the moment. Earlier it stood for the group of all hosts (excluding the routers) in the Link-local scope.
Further reading / References:
- RFC 4291: IP Version 6 Addressing Architecture
- RFC 6890: Special-Purpose IP Address Registries
- RFC 7346: IPv6 Multicast Address Scopes
- RFC 2365: Administratively Scoped IP Multicast (see section 8)
- IANA: IPv4 Multicast Address Space Registry
- IANA: IPv6 Multicast Address Space Registry
- IANA: IPv6 Address Space
Solution 2
I think their purpose is so you can more easily i.e. ping all routers or all hosts etc without having to remember the multicast addresses. I haven't seen them being used anywhere else either.
Related videos on Youtube
Björn Lindqvist
Hello, my name is Björn Lindqvist I'm a consultant. Here is my resume: http://www.bjornlindqvist.se/ I am one of those people who protests a lot against all the closing of perfectly valid and useful questions on SO. Smart people are nice. The world would be a better place if there where more meritocracies in it.
Updated on September 18, 2022Comments
-
Björn Lindqvist over 1 year
I have the following block in my
/etc/hosts
:# The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts
They were inserted by some automagic in Ubuntu and not written by me. I've found lots of documents that say that you should have these lines. But why? Why are they desirable?
My suspicion is that they aren't and are just cruft (except for the first one). Because if you google one of the names, eg
ip6-allrouters
, all you find are references to/etc/hosts
but no one is actually using them.Another way of phrasing this question is, what harm will come unto me or what feature will not function properly if I remove these lines? If the answer is none, can we conclude that they are redundant?
-
Amitav Pajni about 7 yearsI'm pretty sure someone in Debian just made up those names. They don't appear in any official documents and no other distributions, not derived from Debian, have them. If something does break from removing them, it's most likely a bug.
-
Björn Lindqvist about 7 yearsCool! Let's try and find a source for that. If it is true, then that is proof that they are redundant.
-
Amitav Pajni about 7 yearsHow do you prove something doesn't exist?
-
Björn Lindqvist about 7 yearsPerhaps we can find the commit which added the names and ask whoever committed it why he or she did it?
-