0

I'm just playing around with ipv6 and I was trying to use netcat over ipv6. I tried the following and it works.

$ # terminal one 
$ nc -6 -l 7171

$ # terminal two
$ nc -vvv -6 ::1 7171                                                                                                                           
Connection to ::1 7171 port [tcp/*] succeeded!

I tried running ifconfig and got the following output :-

eth0      Link encap:Ethernet  HWaddr 08:00:27:0c:5c:90
          inet addr:192.168.5.177  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe0c:5c90/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:363545 errors:0 dropped:0 overruns:0 frame:0
          TX packets:389270 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:75700504 (75.7 MB)  TX bytes:471219676 (471.2 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:15246 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15246 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1010273 (1.0 MB)  TX bytes:1010273 (1.0 MB)

Next I tried to connect the nc client via the eth0 interface.

$ # terminal one 
$ nc -6 -l 7171

$ # terminal two
$ nc -vvv -6 fe80::a00:27ff:fe0c:5c90 7171
nc: connect to fe80::a00:27ff:fe0c:5c90 port 7171 (tcp) failed: Invalid argument

Why does this happen? Am I doing something obviously wrong?

2

The address you are trying to connect to is a link-local address. When using such addresses you must always specify the network interface. The common notation is a suffix of % and the interface ID. In your example that would become: fe80::a00:27ff:fe0c:5c90%eth0.

And because link-local addresses are local to the link they cannot be routed. Because of this it is usually much easier to give 'normal' IPv6 addresses to your interfaces. If your ISP didn't provide you with IPv6 connectivity then you can either set up a tunnel to e.g. SixXS or Hurricane Electric, or you can use private addresses. Those are called ULA (Unique Local Addresses) in IPv6 and you can randomly generate your own /48 prefix in the block fd00::/8. This prevents conflicts with other ULA addresses when you interconnect networks (VPN tunnels, company mergers etc)

0

You must append the zone index to link local addresses if you want to use them. Under Linux systems, this is the device name. This is, because link-local addresses have the prefix fe80::/10 on every device.

Suppose you have two interfaces (say ethernet and wifi), then something like ping6 fe80::1 is ambiguous - is it fe80::1 on the ethernet or on the wifi device? Both could be perfectly possible, but the system cannot know which one (and it will certainly not try). So you have to tell, like ping6 fe80::1%enp2s0 or so. This is why link-local addresses are somewhat cumbersome to use. (URL encoding of that is particularly awkward.) Next to their importance for neighbor discovery they serve as a last resort if something with IP-address configuration goes wrong, but they are not for regular use - use global addresses or unique local addresses for that.

Offtopic: it is prudent to get yourself familiar with the ip utility from the iproute2 package if you want to play with IPv6, it supersedes and is superior to ifconfig and route.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy