3

In OpenWRT’s gui “LuCI“ the delegated IPv6 Prefix provided by the ISP is diplayed in the status page in overview. Normally it will be shown under “IPv6 WAN Status“ in the “Network“ section like

IPv6 WAN Status  Type: dhcpv6-pd
                 Prefix Delegated: 2001:db8:1234:5678::/56
                 Address: 2001:db8::abcd/128
                 […]

However I would like to figure out the delegated prefix on the command line. I am aware I can get the addresses assigned via ip a or the gateway and other routes via ip r but never manged to retrieve the prefix delegated by the router.

How can I show the delegated ipv6 prefix in the command line interface? Is there a command I am missing or some file it is written into that I am not aware of?

4

You may want to use the jq program to parse the output (available as package in OpenWRT).

Furthermore, if you know that the interface exists, you can call the underlying ubus command directly, saving the overhead for the sanity checks done by ifstatus.

ubus call network.interface.wan_6 status | jq -r '.["ipv6-prefix"][0].address'

Output:

2001:db8:1234:5678::

Note: wan_6 (with underscore) is the name of the automatically generated interface for ipv6. If you have a manually created alias, the name wan6 may apply.

3

The command providing such information is ifstatus

root@openWRT:~# ifstatus wan6
[…]
"ipv6-prefix": [
    {
        "address": "2001:db8:1234:5678",
        "mask": 56,
[…]
0

Both combined:

ifstatus wan6 | jq -r '.["ipv6-prefix"][0].address'

Your Answer

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

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