-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Ability to edit "DHCP static leases" entry after its saved #1700
Comments
Love to see this in the interface. If all else fails it can be implemented as a delete of the old record and a create of the new one, all under the hood. This would create a nicer user expierience. |
Does editing of the static leases list mean that this list will be added to the AdguardHome.yaml file? This would be very nice. Currently the static leases are part of the leased.db, which hashes orso the ip and mac address, making it impossible to provide this preconfigured file from Github for instance. How are mac & ip address hashed btw? |
@MarsWarrior, it will probably be put into some form of a database, although we haven't decided on the format yet. Once we do, exporting and importing the data should be easy. Also, a better place for questions are GitHub discussions. Thanks. |
Moving the static leases into the AdguardHome.yaml file so they are listed like the Client section would be wonderful. :edit: AdGuard Home, version 0.104.3, channel release, arch linux mips
|
+1 This feature is necessary and preventing me moving from PiHole where I can manage this nicely via dnsmasq configuration files. A command line utility, API endpoints or addition to the YAML config are all reasonable approaches - I can work with anything :) |
So there's a way to edit "DHCP static leases" entries? I'm moving from pihole and I have to recreate all the leases by hand |
I just took a look at this... the code is already basically in the repo to decode the leases in package main
import (
"encoding/json"
"fmt"
"log"
"net"
"os"
"time"
)
const dbFilename = "leases.db"
type leaseJSON struct {
HWAddr []byte `json:"mac"`
IP []byte `json:"ip"`
Hostname string `json:"host"`
Expiry int64 `json:"exp"`
}
// Lease contains the necessary information about a DHCP lease
type Lease struct {
// Expiry is the expiration time of the lease. The unix timestamp value
// of 1 means that this is a static lease.
Expiry time.Time `json:"expires"`
Hostname string `json:"hostname"`
HWAddr net.HardwareAddr `json:"mac"`
IP net.IP `json:"ip"`
}
func (l *Lease) UnmarshalJSON(data []byte) (err error) {
type lease Lease
aux := struct {
*lease
HWAddr string `json:"mac"`
}{
lease: (*lease)(l),
}
if err = json.Unmarshal(data, &aux); err != nil {
return err
}
l.HWAddr, err = net.ParseMAC(aux.HWAddr)
if err != nil {
return fmt.Errorf("couldn't parse MAC address: %w", err)
}
return nil
}
func normalizeIP(ip net.IP) net.IP {
ip4 := ip.To4()
if ip4 != nil {
return ip4
}
return ip
}
func main() {
fmt.Println("HI")
data, err := os.ReadFile(dbFilename)
if err != nil {
log.Fatal(err)
}
obj := []leaseJSON{}
err = json.Unmarshal(data, &obj)
fmt.Print(obj)
}
and it will print out some stuff like this (which needs further decoding:
Its pretty straight forward: |
So adguard home also has an api - which maybe is a better way to go: To add a lease you would do something like: curl -X 'POST' \
'http://SERVER_IP/control/dhcp/add_static_lease' \
-H 'accept: */*' \
-u username:password
-H 'Content-Type: application/json' \
-d '{
"mac": "00:11:09:b3:b3:b8",
"ip": "192.168.1.22",
"hostname": "dell"
}' Whereas deleting is: curl -X 'POST' \
'http://SERVER_IP/control/dhcp/remove_static_lease' \
-H 'accept: */*' \
-u username:password
-H 'Content-Type: application/json' \
-d '{
"mac": "00:11:09:b3:b3:b8",
"ip": "192.168.1.22",
"hostname": "dell"
}' If you want to play with the api go to |
Oh even better hit the |
Backup and restore of DHCP config and leases:Get DHCP config and leases
Restoring DCHP config and leases
|
Some time ago, I prepared an Ansible role/tasks for managing static leases in my home setup, if anyone is interested here it is: |
Here's a script you can use to add AGH
|
Updates #1700. Squashed commit of the following: commit b3fdf0a Merge: 507cb9b 4479b32 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Oct 5 12:53:30 2023 +0300 Merge branch 'master' into 1700-update-static-lease commit 507cb9b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Oct 4 18:54:06 2023 +0300 all: upd chlog commit 0736b97 Author: Ildar Kamalov <ik@adguard.com> Date: Wed Oct 4 16:05:35 2023 +0300 client: fix update action commit 351986b Author: Ildar Kamalov <ik@adguard.com> Date: Wed Oct 4 16:01:38 2023 +0300 client: update static lease commit 3c32828 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Sep 28 20:06:29 2023 +0300 dhcpd: fix err msg commit 5b2f8f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Sep 28 16:28:07 2023 +0300 dhcpd: imp code commit a9d24e8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Sep 27 17:43:04 2023 +0300 all: add tests commit 4537857 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Sep 26 20:14:17 2023 +0300 dhcpd: update static lease
@schzhn forgot to mention, but this should be available in the upcoming v0.107.39. |
where should I find this in the newest version? |
@bastiitsab, Settings - DHCP settings - DHCP static leases - Actions tab - Edit button |
thanks! but its only possbile in the GUI? Not in yaml or anywhere on the filesystem? I would also love to bulk edit or export the entries. |
@bastiitsab, |
Updates AdguardTeam#1700. Squashed commit of the following: commit b3fdf0a Merge: 507cb9b 4479b32 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Oct 5 12:53:30 2023 +0300 Merge branch 'master' into 1700-update-static-lease commit 507cb9b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Oct 4 18:54:06 2023 +0300 all: upd chlog commit 0736b97 Author: Ildar Kamalov <ik@adguard.com> Date: Wed Oct 4 16:05:35 2023 +0300 client: fix update action commit 351986b Author: Ildar Kamalov <ik@adguard.com> Date: Wed Oct 4 16:01:38 2023 +0300 client: update static lease commit 3c32828 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Sep 28 20:06:29 2023 +0300 dhcpd: fix err msg commit 5b2f8f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Sep 28 16:28:07 2023 +0300 dhcpd: imp code commit a9d24e8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Sep 27 17:43:04 2023 +0300 all: add tests commit 4537857 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Sep 26 20:14:17 2023 +0300 dhcpd: update static lease
This still does not appear to be implemented yet in the Stable branch on v0.107.42. When you click on the Edit button for a Static DHCP lease, it brings up the New static lease dialog which is empty. I believe that it may be a similar issue to (f44faa9) which was committed recently from issue (#6402). |
@WildByDesign, that's likely what #6534 has reported. Also, it's better to file new issues, provided there are no duplicates, then to respond to closed ones, as they get less attention. |
Very good points. My apologies. I will follow those points in the future. |
Can we please have the ability to edit DHCP static leases after they are added to AdGuard Home.
Another idea: It would be nice to have a description field added :) So there can be notes added to each device. For example mac / ip / hostname / ( Description )
ee:6f:6d:85:0e:39 | 192.168.1.5 | Debian-AdGuard | VM_Server
ee:6f:1d:90:0e:39 | 192.168.1.9 | Android-s20 | WiFi
The text was updated successfully, but these errors were encountered: