I'm trying to understand IPv6 better.
Firstly, I try ifconfig, and I get the following:
eth0 Link encap:Ethernet HWaddr XXXXXXX inet addr:X.X.X.X Bcast:X.X.X.X Mask:XXXXXXXXX inet6 addr: XXXX::XXXX:XXX:XXXX:XXX/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:138752772 errors:0 dropped:0 overruns:0 frame:0 TX packets:67894054 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:67347428211 (67.3 GB) TX bytes:168368922639 (168.3 GB) Interrupt:43So from the above I can assume IPv6 is enabled (correct me if I'm wrong here).
Now if I use ping localhost I get:
64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.026 ms
64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.019 ms
64 bytes from localhost (127.0.0.1): icmp_req=3 ttl=64 time=0.025 ms
...But when I use ping6 localhost I get:
unknown hostHow do I use ping6? Or more specifically, what changes needs to be done to make ping6 localhost work (if possible at all)?
3 Answers
Short answer [rcf4291]
ping6 ip6-localhost # Or the alias you have in /etc/hosts file (See below)
ping6 0:0:0:0:0:0:0:1 # Similar to `ping 127.0.0.1` with 7 `:` instead of 4 `.`
ping6 ::1 # The used analogous of `ping 127.0.0.1`Changes to make working ping6 localhost
If you want to set localhost as alias for both ping and ping6 and it is not already so on your machine, it is enough to write in /etc/hosts file both the lines:
127.0.0.1 localhost
# ... and below
::1 localhost ipv6-localhost ipv6-loopbackFor what it concerns the alias currently used on your system you can check your hosts file, /etc/hosts [1] or in a different place if on a different system [2] .
You may find ip6-localhost,ip6-loopback,ipv6-localhost,ipv6-loopback or localhost itself...
Some words more
I understand your confusion indeed for what I read from the rfc6761 about "Special-Use Domain Names" 6.3 [3], about the name localhost,
Users may assume that IPv4 and IPv6 address queries for localhost names will always resolve to the respective IP loopback address.
so it should be expected as default but:
On the current updated and untouched Ubuntu 14.04.3 LTS
/etc/hostsI found the following section withip6-localhost,ip6-loopback# The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allroutersOn a Suse Enterprise 10 system I found
localhost,ipv6-localhost,ipv6-loopback# special IPv6 addresses ::1 localhost ipv6-localhost ipv6-loopbackOn an old Debian GNU/Linux 8.2 system
localhost,ip6-localhost,ip6-loopback# The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback
That means that, in my limited experience, you should look in your /etc/host file and modify it or use what will you find doing, for example,
ping6 ipv6-localhost # On some systems (maybe on Suse)
ping6 ip6-localhost # On some systems (maybe on Debian/*buntu) 6 Try:
ping6 ::1The result would look like:
# ping6 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.040 ms
(...)
64 bytes from ::1: icmp_seq=9 ttl=64 time=0.037 ms
^C
--- ::1 ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 7998ms
rtt min/avg/max/mdev = 0.035/0.042/0.055/0.011 msUbuntu 14.04.1 LTS (Trusty Tahr):
# ping ::1
ping: unknown host ::1
# ping -6 ::1
ping: invalid option -- '6'
Usage: ping [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface] [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos] [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline] [-W timeout] [hop1 ...] destination
# ping -V
ping utility, iputils-s20121221(The same for ping6 -V.)
localhost is the hostname that resolves to the 127.0.0.1 address. Your /etc/hosts file should have a separate entry for ::1, likely localhost6. So try these:
ping6 ::1
ping6 localhost6 8