openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
160 stars 96 forks source link

odhcpd renews DHCPv6 client leases even after switching to stateless-only mode #151

Closed patrakov closed 4 years ago

patrakov commented 4 years ago

Long time ago, I have installed an OpenWRT router (TP-Link Archer C7 v2) in my network. Now it runs OpenWRT 19.07-rc2. By default, it came with a setup that combines stateless and stateful DHCPv6 on br-lan. Therefore, my desktop PC (which is almost never turned off) has obtained a DHCPv6 lease containing an address, 2a02:17d0:4a6:5700::dba, and keeps renewing it.

Today is December 30. Last time I reconfigured DHCP on December 10, to set it to stateless-only (although SLAAC-only would have worked as well). I have explicitly restarted odhcpd just now, just in case if I forgot to restart it back then.

Even though stateful DHCPv6 is disabled, when the desktop PC thinks that it needs to renew its DHCPv6 lease, the router renews it.

Proof:

root@Archer:~# /etc/init.d/odhcpd restart
root@Archer:~# ubus call dhcp ipv6leases
{
    "device": {
        "br-lan": {
            "leases": [

            ]
        }
    }
}
### waited until the desktop PC decided to renew the lease...
root@Archer:~# ubus call dhcp ipv6leases
{
    "device": {
        "br-lan": {
            "leases": [
                {
                    "duid": "0004ee68edcf72d2c8646b63ccaee52c6a16",
                    "iaid": 2128153145,
                    "hostname": "aep-haswell",
                    "accept-reconf": false,
                    "assigned": 3514,
                    "flags": [
                        "bound"
                    ],
                    "ipv6-addr": [
                        {
                            "address": "2a02:17d0:4a6:5700::dba",
                            "preferred-lifetime": 3210,
                            "valid-lifetime": 3570
                        }
                    ],
                    "valid": 2668
                }
            ]
        }
    }
}

Strangely, my laptop (which is off quite often) does not have a DHCPv6 lease - but well, the software there is not identical.

The /etc/config/dhcp file is:

config dnsmasq
    option domainneeded '1'
    option localise_queries '1'
    option local '/lan/'
    option domain 'lan'
    option expandhosts '1'
    option authoritative '1'
    option readethers '1'
    option leasefile '/tmp/dhcp.leases'
    option resolvfile '/tmp/resolv.conf.auto'
    option nonwildcard '1'
    option localservice '1'
    option enable_tftp '1'
    option tftp_root '/etc/tftpboot'
    option dhcp_boot 'netboot.xyz-undionly.kpxe'
    option rebind_protection '0'

config dhcp 'lan'
    option interface 'lan'
    option start '100'
    option limit '150'
    option dhcpv6 'server'
    option ra 'server'
    option ra_management '0'
    option force '1'
    option leasetime '72h'

config dhcp 'wan'
    option interface 'wan'
    option ignore '1'

config odhcpd 'odhcpd'
    option maindhcp '0'
    option leasefile '/tmp/hosts/odhcpd'
    option leasetrigger '/usr/sbin/odhcpd-update'
    option loglevel '4'

# ...and some "config host" entries.

I would expect the 2a02:17d0:4a6:5700::dba lease to go away automatically.

patrakov commented 4 years ago

Attaching pcapng file that illustrates the issue: initially odhcpd replies with NoBinding, but later accepts the client's idea about the lease. 922-927.pcapng.zip

dedeckeh commented 4 years ago

From R19.07 onwards odhcpd can be configured to refuse statefull DHCPv6 requests by setting dhcpv6_na and dhcpv6_pd to 0 in the dhcp lan config

patrakov commented 4 years ago

Is it possible to have both prefix delegation and no IPv6 addresses other than the statelessly autoconfigured ones?

dedeckeh commented 4 years ago

I don't completely understand your question; can you clarify the question a bit more in detail ?

patrakov commented 4 years ago

OK, let me reword. Your comment mentions setting dhcpv6_pd to 0, and I don't like that, because I have one client that does want a delegated prefix (for virtual machines). Is there any way around that? Or is it a protocol limitation, that a delegated prefix must come with an IPv6 address assigned through non-SLAAC mechanism, and if one client wants it, then everyone should get such address?

dedeckeh commented 4 years ago

No you can just set dhcpv6_na to 0 and odhcpd will not assign a statefull IPv6 address anymore while it will assign a delegated prefix

patrakov commented 4 years ago

Thanks, will test tomorrow.

dedeckeh commented 4 years ago

I will close this issue; feel free to re-open if the above described proposal does not fix your issue