21

when I try: $ ip -6 addr I get something like:

inet6 fe80::d773:9cf0:b0fd:572d/64 scope link

if I try to ping that from the machine itself:

$ ping6 fe80::d773:9cf0:b0fd:572d/64
unknown host

$ ping6 fe80::d773:9cf0:b0fd:572d
connect: Invalid argument

What am I doing wrong?

marathon
  • 883
  • 3
  • 10
  • 25

2 Answers2

30

Any IPv6 address that starts with fe80: is the equivalent of IPv4 169.254.*.* address, i.e. it's a link-local address, reachable only in the network segment it's directly connected to, using the NIC that connects to that segment specifically. Unlike IPv4, however, it is perfectly normal for a NIC to have both the link-local IPv6 address and one or more global IPv6 addresses simultaneously.

Since a fe80: IPv6 address is link-local, you must specify the network interface you want to use when pinging it.

Example:

$ ping6 fe80::beae:c5ff:febe:a742
connect: Invalid argument

$ ping6 -I eth0 fe80::beae:c5ff:febe:a742
PING fe80::beae:c5ff:febe:a742(fe80::beae:c5ff:febe:a742) from fe80::beae:c5ff:febe:a742%eth0 eth0: 56 data bytes
64 bytes from fe80::beae:c5ff:febe:a742%eth0: icmp_seq=1 ttl=64 time=0.182 ms
64 bytes from fe80::beae:c5ff:febe:a742%eth0: icmp_seq=2 ttl=64 time=0.167 ms
...

You can also append the interface at the end of the address by using the % sign: ping6 fe80::beae:c5ff:febe:a742%eth0.

This requirement is only for link-local IPv6 addresses: you can ping globally routable IPv6 addresses without specifying the interface.

$ ping6 2a00:1450:400f:80a::200e  # that's ipv6.google.com
PING 2a00:1450:400f:80a::200e(2a00:1450:400f:80a::200e) 56 data bytes
64 bytes from 2a00:1450:400f:80a::200e: icmp_seq=1 ttl=55 time=17.6 ms
64 bytes from 2a00:1450:400f:80a::200e: icmp_seq=2 ttl=55 time=19.6 ms
...
telcoM
  • 87,318
  • 3
  • 112
  • 232
  • It also says `scope link` right in the output :) – hobbs Feb 12 '18 at 10:43
  • 4
    Just as an appendix to the answer: your can also specify the interface at the end of the address: `ping6 fe80::beae:c5ff:febe:a742%eth0` – Ferrybig Feb 12 '18 at 12:04
  • @Ferrybig: thanks for reminding me, updated my answer. – telcoM Feb 13 '18 at 08:36
  • 1
    Note that if you want to ping a remote ipv6 address, your home router also has to support ipv6. Older routers do not always have the software/firmware update to support a connection over ipv6. You will most likely get the following message: `ping6: UDP connect: No route to host` – Daniel Gelling Jul 26 '18 at 02:07
9

From man ping6, you must tell ping which interface you are using:

-I interface address

Set source address to specified interface address. Argument may be numeric IP address or name of device. When pinging IPv6 link-local address this option is required.

For example, if your interface is eth0:

ping6 -I eth0 fe80::xxxxxx

or, without the -I option:

ping6 fe80:xxxxxx%eth0
garethTheRed
  • 33,289
  • 4
  • 92
  • 101