[solved] DHCPv6-PD how to configure length of delegated prefix

I have two OpenWrt hosts host A an host B. Host A is upstream of host B. The interface of host A where host B is connected to has an address with prefix /56. Host A has odhcpd running as DHCPv6-Server and delegates a prefix of /62 to host B.

Now I would like Host B to get a /58 prefix instead. So I configured Host B with reqprefix '58'. The problem is, host B still gets a prefix of /62. I verified with tcpdump that host A indeed requests /58 and that it receives a /62-prefix.

There must be some configuration option that allows to specify the mininum prefix length a DHCPv6 client can get, but I can't find it anywhere. Or alternatively, there may be a way to statically configure per client the prefix delegated to it. I looked here https://openwrt.org/docs/techref/odhcpd#dhcpv6 and here https://openwrt.org/docs/guide-user/network/ipv6/configuration#slaac_and_dhcpv6 and here https://openwrt.org/docs/guide-user/base-system/dhcp#dhcp_pools , searched the forum, even looked in luci.

1 Like

It might help if you show the output of:

ubus call system board
ifstatus wan6

show the output of the ipv6-address and ipv6-prefix stanza redact the first 8 characters of the IPv6 address

The first router needs a value large enough with ip6assign and the other router needs to explicit request the PD size on its dhcpv6 client network stanza.

1 Like

Host A, ifstatus wan6

...
    "ipv6-address": [
        {
            "address": "fe80::ff:2ab",
            "mask": 128
        }
    ],
    "ipv6-prefix": [
        {
            "address": "2xxx:xxxx:xxxx:4000::",
            "mask": 50,
            "class": "wan6",
            "assigned": {
                "sub1": {
                    "address": "2xxx:xxxx:xxxx:4000::",
                    "mask": 56
                },
                "sub2": {
                    "address": "2xxx:xxxx:xxxx:4100::",
                    "mask": 56
                }
            }
        }
    ],
...

Host A, ifstatus sub2

...
    "ipv6-prefix-assignment": [
        {
            "address": "2xxx:xxxx:xxxx:4100::",
            "mask": 56,
            "local-address": {
                "address": "2xxx:xxxx:xxxx:4100::1",
                "mask": 56
            }
        }
    ],
...

Host B, ifstatus wan6

...
    "ipv6-address": [
        {
            "address": "2xxx:xxxx:xxxx:4100:yyyy:yyff:feyy:yyyy",
            "mask": 64
        },
        {
            "address": "2xxx:xxxx:xxxx:4100::242",
            "mask": 128
        }
    ],
    "ipv6-prefix": [
        {
            "address": "2xxx:xxxx:xxxx:4104::",
            "mask": 62,
            "class": "wan6",
            "assigned": {

            }
        }
    ],
...

Not sure how the output of ubus call system board is useful. It's running in qemu.

The first router has ip6assign confgured to 56. So in theory it should be able delegate prefixes from /57 upwards.

Correct sub2 has a prefix of 56 so it should be able to handout a prefix of 58 unless there are other clients which are requesting large prefixes, so that is something to check.
I have the same setup (not qemu but just regular routers) and my downstream router can request a PD of 58 with option reqprefix

So maybe other clients of sub2 requesting large prefixes (or a qemu quirk), I use 24.10.1 on both routers.

Use ifstatus with the UCI interface name to see details about an interface.

When a prefix of the requested size is not available it will assign a smaller one. I do not know exactly how that works though. Prefix delegation is not an integral kernel feature; OpenWrt specific code somewhere does it.

If you do not need the openwrt integration then dump udhcp6d and dnsmasq and use kea and bind. :person_shrugging:

Before 2023, the /62 delegated prefix length was hard-coded in odhcpd; you could not change it.

Now you can:

config dhcp 'pd'
    ...
    option dhcpv6_pd_min_len '60'

See https://git.openwrt.org/?p=project/odhcpd.git;a=commitdiff;h=52112643308bb02a3b4fa2894dd7d4340ba4a237

EDIT: This answer is based purely on code search. I have not tested whether it works.

4 Likes

Nice. Thanks for the finding! Something I need to check out too!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.