Can I query whether I have ipv6 connectivity?

This is a decent way, which returns quickly if there is not connectivity

root@router6:~# ping -6 icanhazip.com
PING icanhazip.com (2606:4700::6812:7261): 56 data bytes
ping: sendto: Permission denied
root@router6:~#

Is there a better way of doing this from the command line which does not generate network traffic? I realize that the result, if true, might not reflect there is actual connectivity there (for instance if an upstream link is down).

What I want is something fast and easy to test before doing some ipv6 busy work.

If you don't generate any traffic, how would you tell if you have ipv6 connectivity?

I would first run

ip -6 a
ip -6 r
2 Likes

Yes, look for an IPv6 default route. This is usually the link-local IP6 of the next router toward the Internet.

ifstatus wan6 or related ubus calls could also be useful.

2 Likes

I think my example ping is not actually generating any wire traffic, but it knows immediately that there is not ipv6 connectivity. So something like that

ip -6 route | grep default
This seems like a pretty good scriptable command line hint that there is likely ipv6 connectivity. I'll try this.

Or even better
ip -6 route show default | grep default