DHCPv6 from upstream /64 prefix from ISP's LTE router

I further dug into how DHCPv6 works in OpenWrt and found that odhcp6c obtains information from the WAN IPv6 interface and calls the script /lib/netifd/dhcpv6.script with the obtained information in environment variables and the action performed in the arguments.

My findings:

I created the custom script /etc/odhcp6c.user that prints the output of set to a file so that I could see what is happening under the hood.

In the dhcpv6.script file,

  • The environment variable PREFIXES is supposed to contain the list of prefixes obtained from prefix delegation, and it can be further utilised by DHCPv6. In my case, this variable was not set, probably because the prefix came from RA, and not from PD.

  • Further below, I found this interesting part that talks about RFC 7278. This seemed to be exactly what I wanted - extending the /64 prefix that is recieved on the WAN. On inspecting using my custom script, I noticed that the $EXTENDPREFIX variable was not set. Where did this come from? :thinking:

I searched through OpenWrt's commit history and found 2 commits (at the time of writing) related to this.

An option called extendprefix seems to be introduced in this commit that is setting the $EXTENDPREFIX variable to 1. This option is not documented in the wiki for IPv6 configuration.

I changed my network.usb6 configuration to include network.usb6.extendprefix='1' and set dhcp.lan.dhcpv6 and dhcp.lan.ra back to 'server', and now it works!

I believe this missing option should be added to the wiki.

2 Likes