大网数据广告活动
服务器运维问答

Show delegated ipv6 prefix at command line in OpenWRT

· 52CE 我爱测

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 Pre…

问题原文

原帖链接 · 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*

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-05-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。