Macos – the relevance of “fe80::1%lo0 localhost” in /etc/hosts

hosts-fileipv6macosnetworking

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

Best Answer

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.