Stupid IPv6 tricks

I recently wanted to find the IPv6 address of a computer on my network. However, since I’m using autoconfiguration, I had no way of knowing what it was, unless I walked the 5 feet and checked it out on the computer itself. Instead, I went looking and found this IPv6 trick to get a list of addresses on your network.
It returns the link local addresses (so it only works as long as you’re on the same link).
But I needed to know the global IPv6 address. Fortunately for me, the only addresses on this link are my computer, the gateway and the computer I wanted to find. I got this from the above ping6 trick (addresses may have been changed to protect the guilty):

$ ping6 -I eth2 ff02::1
PING ff02::1(ff02::1) from fe80::92e6:baff:febd:6532 eth2: 56 data bytes
64 bytes from fe80::91e6:baff:feba:6532: icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from fe80::211:f3ff:fe67:8fee: icmp_seq=1 ttl=64 time=0.131 ms (DUP!)
64 bytes from fe80::212:3fff:fef6:2c23: icmp_seq=1 ttl=64 time=0.149 ms (DUP!)
^C
--- ff02::1 ping statistics ---
1 packets transmitted, 1 received, +2 duplicates, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.045/0.108/0.149/0.046 ms

I know what my link local is (from ifconfig), and I know what my router’s link local is (from ip -f inet6 neigh) [shortened to ip -6 n, thanks to @barttrojanowski]:

$ ip -6 n
fe80::212:3fff:fef6:2c33 dev eth2 lladdr 00:12:3f:f6:2c:23 router REACHABLE
2001:db8:81e5::1 dev eth2 lladdr 00:12:3f:f6:2c:23 router REACHABLE

So that leaves me with fe80::211:f3ff:fe67:8fee. To get the global address, I drop fe80 and tack on my subnet of 2001:db8::/64
$ ping6 2001:db8::211:f3ff:fe67:8fee
PING 2001:db8::211:f3ff:fe67:8fee(2001:db8::211:f3ff:fe67:8fee) 56 data bytes
64 bytes from 2001:db8::211:f3ff:fe67:8fee: icmp_seq=1 ttl=64 time=9.73 ms
64 bytes from 2001:db8::211:f3ff:fe67:8fee: icmp_seq=2 ttl=64 time=0.113 ms
^C
--- 2001:db8::211:f3ff:fe67:8fee ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.113/4.923/9.733/4.810 ms

Leave a Reply