Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dynamic lease from our lease index after a static lease is added #1531

Closed
Rochey opened this issue Mar 31, 2020 · 5 comments
Closed
Assignees
Milestone

Comments

@Rochey
Copy link

Rochey commented Mar 31, 2020

I've set up my DHCP reservations outside of my DHCP scope and everything seems to be working but I thought I'd ask if this is a supported configuration?
My DHCP reservations are between 10.10.10.3 - 60 and my DHCP pool is 10.10.10.200 - 250.

Also, whats the easiest way to configure a new device to use a DHCP reservation?
I've been adding the device to the network
getting a 10.10.10.200+ address
creating a DHCP reservation from the mac address
then rebooting the device (sometimes works)
rebooting the AGH device (sometimes works)
rebooting both devices above (sometimes works)
rebooting Google wifi and the above (sometimes works)

It doesn't seem to be very consistent when trying to get the end device to use it's DHCP reservation.
It would be nice to be able to select the device in the DHCP list and create a reservation from that, and then force delete the DHCP entry so that the device gets the new DHCP reservation.

@szolin
Copy link
Contributor

szolin commented Apr 3, 2020

DHCP reservations outside of my DHCP scope

We allow static leases outside of dynamic DHCP lease range.

force delete the DHCP entry so that the device gets the new DHCP reservation

Once the device gets its lease - it won't request a new one until the current lease is expired. Restarting the device should force that.

You can also try setting a small lease TTL (1 minute) when you're configuring a new device, then set lease TTL back to normal after you've set up a static lease.

If you know the device MAC address, you can set a static lease for it before setting the device online. Otherwise, it's all expected behaviour.

@Rochey
Copy link
Author

Rochey commented Apr 5, 2020

Thanks for coming back to me.
I'm glad that DHCP reservations outside the DHCP scope is supported.

I'm still having trouble with getting the end devices to get their static IP addresses though.
I just got a new OnePlus phone and it received an address of 10.10.10.203 (in my dhcp scope).
I then created a static DHCP reservation 10.10.10.21 using the mac address.
I rebooted the phone and waited for the lease to expire in AGH.
I joined the network expecting to get the new 10.10.10.21 address but the phone still got 10.10.10.203 instead.
I had to do the above again and reboot the AGH pi device and only then did it pick up the 10.10.10.21 address.
I don't know what was holding on to the 10.10.10.203 information??

Is there a possibility that AGH isn't flushing the reservation until a reboot sometimes?
Or if there isn't an issue, is there anyway we can make the process better?

@szolin
Copy link
Contributor

szolin commented Apr 7, 2020

I had to do the above again and reboot the AGH pi device and only then did it pick up the 10.10.10.21 address.

It may be a bug. Can you enable verbose logging? Repeat the same steps with your phone once again and attach the logs here. AGH will print the info on which leases it reserves and what DHCP packets it receives from your device.

@Rochey
Copy link
Author

Rochey commented Apr 7, 2020

Hi szolin,
I've got the log information for you. I did the same test but with an Android Shield Tablet.
It's mac address is 00:04:4b:2d:42:1f.
It first got the address x.x.x.203
I created a static DHCP using the mac address for x.x.x.25
I waited for the .203 lease to expire (set to 60secs)
I turned off WIFI on the tablet and then turned it on again = still get x.x.x.203 address
I waited for the .203 lease to expire (set to 60secs)
I rebooted the Shield tablet = still got x.x.x.203 address
I then rebooted the AGH pi device = Shield tablet got x.x.x.25

AGH.log

Any more questions or tests let me know.

@szolin
Copy link
Contributor

szolin commented Apr 7, 2020

Thank you for the logs!
We should remove dynamic lease from our lease index after a static lease is added.

[debug] github.com/AdguardTeam/AdGuardHome/dhcpd.(*Server).handleDiscover(): Message from client: Discover.  ReqIP: <nil>  HW: 00:04:4b:2d:42:1f  Hostname: android-e2efbaed53a37cbf
[debug] github.com/AdguardTeam/AdGuardHome/dhcpd.(*Server).printLeases(): Lease #36: hwaddr 00:04:4b:2d:42:1f, ip 192.168.86.203, expiry 2020-04-07 15:01:57.916935046 +0100 BST m=+264.007369770
[debug] github.com/AdguardTeam/AdGuardHome/dhcpd.(*Server).printLeases(): Lease #37: hwaddr 00:04:4b:2d:42:1f, ip 192.168.86.25, expiry 1970-01-01 01:00:01 +0100 BST
[debug] github.com/AdguardTeam/AdGuardHome/dhcpd.(*Server).handleDHCP4Request(): Message from client: Request.  IP: 0.0.0.0  ReqIP: 192.168.86.203  HW: 00:04:4b:2d:42:1f
[debug] github.com/AdguardTeam/AdGuardHome/dhcpd.(*Server).handleDHCP4Request(): Replying with ACK.  IP: 192.168.86.203  HW: 00:04:4b:2d:42:1f  Expire: 2020-04-07 15:01:58.327539252 +0100 BST m=+264.417974069

@szolin szolin self-assigned this Apr 7, 2020
@szolin szolin added this to the v0.102 milestone Apr 7, 2020
@szolin szolin added the bug label Apr 7, 2020
@ameshkov ameshkov changed the title Quesitons about DHCP reservations and DHCP scope? Remove dynamic lease from our lease index after a static lease is added Apr 8, 2020
@adguard adguard closed this as completed in fcaed16 Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants