问题原文
原帖链接 · karlsebal · CC BY-SA 4.0
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?
社区高分解答
原帖链接 · Adrian W · CC BY-SA 4.0
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. You can list all interfaces:
ubus list network.interface*
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
