Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a squeeze box that I'm testing ipv6 on... eth3 is the interface... if I set up an 'normal' ipv6 address (::101:c0a8:3132/120), I see expected results in ifconfig...

eth3      Link encap:Ethernet  HWaddr 00:02:b3:9a:af:6d  
          inet6 addr: fe80::202:b3ff:fe9a:af6d/64 Scope:Link
          inet6 addr: ::101:c0a8:3132/120 Scope:Global

But if I configure an IPv4-mapped IPv6 address, I don't see part of the address...

[mpenning@hotcoffee EX4200_PC5448]$ sudo ip -6 addr del ::101:c0a8:3132/120 dev eth3
[mpenning@hotcoffee EX4200_PC5448]$ sudo ip -6 addr add ::ffff:192.168.13.236/120 dev eth3
[mpenning@hotcoffee EX4200_PC5448]$ ifconfig eth3
eth3      Link encap:Ethernet  HWaddr 00:02:b3:9a:af:6d  
          inet6 addr: 192.168.13.236/120 Scope:Global
          inet6 addr: fe80::202:b3ff:fe9a:af6d/64 Scope:Link

Shouldn't this address display as ::ffff:192.168.13.236/120 instead of 192.168.13.236/120?

I'm also having a problem pinging when the IPv4-mapped IPv6 address is assigned, so now I wonder whether this related to the unexpected display in ifconfig, or something wrong on the other side.

EDIT:

Using ip addr show eth3...

[mpenning@hotcoffee ~]$ ip addr show eth3
5: eth3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:02:b3:9a:af:6d brd ff:ff:ff:ff:ff:ff
    inet6 ::ffff:192.168.13.236/120 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::202:b3ff:fe9a:af6d/64 scope link 
       valid_lft forever preferred_lft forever
[mpenning@hotcoffee ~]$
share|improve this question
1  
Step 1: stop using ifconfig. –  Juliano Apr 22 '11 at 18:10
    
@Juliano, I have no credulity in your three word sentence. Elaborate –  Mike Pennington Apr 22 '11 at 18:13
2  
in my answer. Ifconfig was last updated ten years ago; it uses the obsolete ioctl() interface instead of the new netlink and thus doesn't support anything past Linux 2.2. It is an abomination that distros still include it. Also, discussion, Debian bug, etc. –  Juliano Apr 22 '11 at 18:45
    
@Juliano, very useful info... I had no idea it was so bad. Thank you –  Mike Pennington Apr 22 '11 at 18:47
add comment

1 Answer

up vote 3 down vote accepted

IPv4-mapped IPv6 addresses are not supposed to be assigned to IPv6 interfaces or for IPv6 native communication. Not on current Linux at least. Add normal IPv4 addresses using ip addr add, without the -6 flag and in normal IPv4 notation.

sudo ip addr add 192.168.13.236/24 dev eth3

And also, again, do not use ifconfig. It is old, deprecated, broken and superseded by iproute2. It will not display IPv6 addresses correctly, and will not display multiple IPv4 addresses on the same interface without aliases.


I'll clarify the discussion in the comments below here, since it is too big to post as another comment.

It doesn't make sense to add IPv4 addresses to the IPv6 stack, even if by converting them to IPv4-mapped IPv6 addresses. The IPv6 stack deals with IPv6 addresses and transmit IPv6 packets; the IPv4 stack deals with IPv4 addresses and transmit IPv4 packets.

Adding the address to the interface and pinging it may work probably because there is some sanity check missing in the kernel code that adds addresses to interfaces.

IPv4-mapped IPv6 addresses exist so that you can use IPv6 sockets (important note: that is application-level) to communicate to IPv4 hosts. You do not need to add a IPv4-mapped IPv6 address to your interfaces in order to communicate to them using IPv6. Try it:

ssh ::ffff:127.0.0.1

It will work transparently even though ::ffff:127.0.0.1 (IPv6) is not registered in the IPv6 stack for the loopback interface (lo). It works because 127.0.0.1/8 (IPv4) is. The system actually uses IPv4 packets even though you provided an IPv6 address. You may check this with wireshark or tcpdump. This is also valid when you receive an IPv4 packet or connection using an IPv6 socket bound/listening to the IPv6 wildcard address.

Note that ICMP and ping works differently because the API for ICMP sockets is completely different between IPv4 and IPv6. ping6 actually creates a raw ICMPv6 packet with the address given, which doesn't make sense in the wire. IMO this may be safely considered a bug, both ping6 and the kernel should fail earlier before injecting IPv6 packets with IPv4 addresses into the wire, or allowing such addresses to exist in the IPv6 stack.

share|improve this answer
    
@Juliano, thanks for the information... this was to use dual-stack ipv6, not for an ipv4 address. –  Mike Pennington Apr 22 '11 at 18:41
    
@Mike, dual-stack means that the system supports both IPv4 and IPv6, each one on its own stack. ip -4 a will show you the IPv4 one, ip -6 a will show you the IPv6 one. Simply ip a will show both, plus MAC addresses. –  Juliano Apr 22 '11 at 18:49
    
@Juliano... are we disagreeing about this? –  Mike Pennington Apr 22 '11 at 18:51
    
It depends, perhaps I'm confused by your distinction between "dual-stack ipv6" and "ipv4 address". –  Juliano Apr 22 '11 at 19:01
    
@Juliano, I have no idea what you are talking about and why you keep mentioning ipv4. Look at the output of ifconfig above... do you see family inet or family inet6? –  Mike Pennington Apr 22 '11 at 19:07
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.