5

I have an entry like this in /etc/hosts:

fe80::XXXX:XXff:feXX:XXXX%enp0s25 test-ipv6

This is a link-local address. I've masked out my MAC address (with the 7th most significant bit flipped) for this post.

I can ping the address, but pinging test-ipv6 gives

ping: test-ipv6: Name or service not known
  • Why doesn't it work?
  • Is there a different way to assign an IPv6 link-local address to a hostname?

I'm using Arch Linux with kernel version 4.17.2.

EDIT: this is mostly a duplicate of IPv6 scope ID in /etc/hosts.

5
  • you probably instead want to use a not link-local address as whatever reads hosts doubtless does not know about what interface the address is supposed to be on
    – thrig
    Jun 28, 2018 at 22:31
  • @thrig Yes, with a link-local address you always have to specify the interface (in my example this is %enp0s25). Jun 28, 2018 at 22:33
  • Related question: unix.stackexchange.com/questions/174767/…. TL;DR: It's not supported by the lookup routines, and seems to be a long-standing issue. My guess is that ping special-cases literal link-local addresses.
    – ErikF
    Jun 29, 2018 at 1:18
  • @ErikF That question is basically asking for the same thing as my question (although I'll leave my question to make it easier to find for people with my problem). Note that the special case for link-local addresses is in Linux' network stack, as ping shouldn't even try to resolve them if someone gives IP addresses to ping (independent of whether they are link-local or not). Jun 29, 2018 at 3:23
  • Does this answer your question? IPv6 scope ID in /etc/hosts Aug 3 at 12:54

1 Answer 1

0

Use Link-local Multicast Name Resolution (LLMNR) or Multicast DNS (mDNS) (implemented by systemd-resolved) on your network. With LLMNR or mDNS, the hosts on the local network respond with their own hostnames. On a modern Linux distribution, the scope id for a link-local IPv6 address is returned by the resolver and everything should work even when using link-local IPv6 addresses.

Depending on your Linux distribution, you may already have LLMNR enabled: try

ping -6 somehost

(or ping6) where somehost is the host on the same LAN you are trying to reach.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .