Show delegated ipv6 prefix at command line in OpenWRT

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.

Tags:

Ipv6

Openwrt