Ipv6 For the Linux Commandline

Credit to http://www.linux.com/learn/tutorials/428331-ipv6-crash-course-for-linux

LAN Discovery

Want to find out if you have IPv6 neighbors on your LAN?

ping6 -c4 -I eth0 ff02::1

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Link-local addresses are all in the fe80::/10 address range. These are comparable to the address block in IPv4, the stateless address auto-configuration blocks. The IPv6 protocol requires link-local addresses, even if you are using other assigned addresses.

Now that you have connected to two LAN IPv6 hosts they are in the IPv6 neighbor table, which is just like the IPv4 ARP (address resolution protocol) table. You can read this table with the ip command:

ip -6 neigh show

Using Hostnames

We’ll get to the proper “leet” network administrator method of assigning hostnames in a future installment; for today let’s use good old reliable /etc/hosts. Let’s say you have three PCs in your little link-local LAN: fatfreddy, phineas, and franklin. You can use these fine hostnames over IPv6 as easy as pie. You’ll make identical entries in the /etc/hosts file of each PC, like this:

fe80::20b:6aff:feef:7e8d  fatfreddy
fe80::221:97ff:feed:ef01  phineas
fe80::3f1:4baf:a7dd:ba4f  franklin

Now you can ping6 by hostname:

ping6 -I eth0 phineas
PING phineas(phineas) from fe80::221:97ff:feed:ef01 eth0: 56 data bytes
64 bytes from phineas: icmp_seq=1 ttl=64 time=17.3 ms


SSH and SCP both speak IPv6. Warning: there are some syntax gotchas, so pay attention. You can log in and copy files on your ad-hoc IPv6 link-local network just like on your old-fashioned IPv4 network. If you have IPv6 name services set up then you don’t do anything differently. For example, you can login via ssh as a different user in the usual way, ssh user@remotehost. Copying a file is also exactly the same: scp filename user@remotehost:/home/username/directory/.

It gets tricky using your IPv6 link-local addresses. This is how you establish an SSH session:

ssh phineas@fe80::221:97ff:feed:ef01%eth0

Again, you must specify the network interface name on your PC, and you must do it as shown, appended with a percent sign and no spaces. scp has its own fiendish syntax quirks:

$ scp test.txt phineas@\[fe80::221:97ff:feed:ef01%eth0\]:
phineas@fe80::221:97ff:feed: ef01%eth0's password:
test.txt 100%   19     0.0KB/s   00:00

The IPv6 address must be enclosed in square braces, including the interface name, and the braces must be escaped.

What is My IPv6 Address?

The ifconfig -a command displays complete information on all of your network interfaces, both physical and virtual. When you know which interface to query you can quickly narrow it down with grep:

$ ifconfig eth0 |grep "inet6 addr:"

          inet6 addr: fe80::20d:b9ff:fe05:25b4/64 Scope:Link


Leave a Reply

Your email address will not be published. Required fields are marked *