What is the relevance of "fe80::1%lo0 localhost" in /etc/hosts?
Solution 1
It's an IPv6 address. The fe80:: block is reserved for link-local addresses. Link local addresses are used for packets sent only to directly connected devices (not routed). The network discovery protocol (NDP) is the biggest user of link-local addresses (NDP sorta replaces ARP and DHCP in IPv6).
Each of your interfaces will have a different link-local address starting with fe80:: and (typically) ending with a modified version the interface's MAC address (EUI-64 format) to ensure you have a unique address on your segment. In the case of your loopback interface, there isn't anything else connected to it, so it can use the address of fe80::1 without fear of conflict, which is why fe80::1 is typically used as the "localhost" address--the IPv6 equivalent of 127.0.0.1.
Solution 2
Excellent answer above from eater. IPv6 link-local addresses, as said above, of the form fe80:*
in fact fe80::/10
meaning the top ten bits only are matched against fe8*:*
so the range is fe80::0 .. febf:*
. Check my arithmetic.
These addresses are the equivalent of 169.254.\*.\*
addresses in IPv4, although the IPv4 counterparts are much much less well used.
It is very common to have several addresses in ipv6 but only one in IPv4. Having both an fe80::
adress and a globally meaningful routable IPv6 address (such as 2001:*
for example) is the rule not the exception. Unfortunately applications and operating systems don't tend to do the same in IPv4, that is, interfaces tend not to have several IPv4 addresses, and I haven't seen the case where an interface has say a 169.254.\*.\*
address and another type of address simultaneously.
Simultaneously using the two types in IPv4 would prevent a lot of pain and suffering when for example kit powers up in the wrong order, pcs power up before routers or servers and the PCs assign themselves a 169.254.\*.\*
address and stick with only that rather than adding a second globally meaningful, routable address when they later find out from their router or server where they are supposed to be on the internet.
Related videos on Youtube
Admin
Updated on September 17, 2022Comments
-
Admin over 1 year
Following are the entries in my
/etc/hosts
.I was wondering what is the last entry (
fe80::1%lo0 localhost
) for.127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost
-
eater over 13 yearsI should also mention that the "%lo0" part is necessary because any link-local address would be ambiguous if it weren't explicitly tied to an interface.
-
citrin about 6 yearsThere is no NDP on loopback interfase and
::1
used as IPv6 equivavelent of127.0.0.1
, notfe80::1%lo0
. -
Ivan about 5 yearsWhat if my actual loopback interface name is (as reported by ifconfig) simply
lo
and notlo0
? Also why include 2 IPv6 hosts records for localhost?