summaryrefslogtreecommitdiff
path: root/src/op_mode/dhcp.py
AgeCommit message (Collapse)Author
2026-06-18Merge pull request #5237 from indrajitr/dhcp-leases-extended-optionsChristian Breunig
dhcp: T8941: Support filter and sorting combination on DHCPv4/v6 server lease entries in op mode
2026-05-29dhcp: T8941: Apply guards for empty or missing mapping keysIndrajit Raychaudhuri
2026-05-29dhcp: T8941: Add missing `hostname` as valid sort keyIndrajit Raychaudhuri
Add `hostname` as a valid sort key for both DHCPv4 and DHCPv6 leases and static mappings.
2026-05-29dhcp: T8933: Honor system timezone for timestamp display in op modeIndrajit Raychaudhuri
The time displayed in DHCP v4/v6 server lease op-mode commands should honor system timezone and not force UTC timezone. This would keep the timestamps in the output of `show log dhcp server` or `show log dhcpv6 server` consistent with the timestamps in the output of `show dhcp server leases` or `show dhcpv6 server leases` commands.
2025-12-09T8078: dhcpv6: allow lease renew for pd & parametersChris Cowart
The renew command will refuse to restart the dhcp6c process for an interface unless it is configured to request an address, but the client may also be running to manage parameters and/or prefix delegations.
2025-10-01vyos-dhcp: T7895: rename "DHCP Server" column to "Lease Time"vanitypurpose
(cherry picked from commit e7c8867b75f6855e93792ddd255bf0ad2b2464b1)
2025-09-22kea: T7281: Use correct Kea unit filessarthurdev
2025-09-18Merge pull request #4723 from sarthurdev/kea3.0Viacheslav Hletenko
kea: T7821: Update Kea to 3.0
2025-09-15Merge pull request #4689 from davi2367/vrf-dhcpDaniil Baturin
T6211: Fix kea VRF op-mode commands
2025-09-14kea: T7821: Update Kea to 3.0sarthurdev
2025-09-01Merge branch 'current' of https://github.com/nvandamme/vyos-1x into currentNicolas Vandamme
2025-09-01Merge branch 'vyos:current' into currentNicolas Vandamme
2025-09-01op-mode: T5992: show dhcpv6 leases with (mostly) the same fields as dhcp leasesNicolas Vandamme
2025-09-01Merge branch 'current' into currentNicolas Vandamme
2025-09-01T6211: Fix kea VRF op-mode commandsDavid Vølker
2025-08-20kea: T6211: fix error in op_mode for VRF support for KEADavid Vølker
2025-08-19Merge pull request #4508 from davi2367/vrf-dhcpDaniil Baturin
kea: T6211: add VRF support for KEA dhcp server
2025-08-15kea: T6211: add VRF support for KEA dhcp serverDavid Vølker
2025-06-28T7591: remove copyright years from source filesChristian Breunig
The legal team says years are not necessary so we can go ahead with it, since it will simplify backporting. Automatically removed using: git ls-files | grep -v libvyosconfig | xargs sed -i -E \ 's/^# Copyright (19|20)[0-9]{2}(-[0-9]{4})? VyOS maintainers.*/# Copyright VyOS maintainers and contributors <maintainers@vyos.io>/g' In addition we will error-out during "make" if someone re-adds a legacy copyright notice
2025-02-17dhcp: T7052: Clean up unnecessary params in formatter methodsIndrajit Raychaudhuri
The formatter methods are mostly `family` agnostic now.
2025-01-26T6998: Remove vestigial helper and reformatIndrajit Raychaudhuri
2025-01-26T6998: dhcpy.py - fix datetime to be timezone awaremetron2
2025-01-16ruff: T6583: Reformat to comply with code styleIndrajit Raychaudhuri
2025-01-16dhcp: T7052: Rename and simplify functions for consistencyIndrajit Raychaudhuri
2025-01-16dhcp: T7052: Refactor kea dhcp op-mode functions to vyos.keaIndrajit Raychaudhuri
Relocate the kea dhcp op-mode functions to kea helper functions in vyos.kea. This allows the functions to be reused by other scripts, not just op-mode wrappers. This moves the source of truth for the op-mode commands to the actual running kea instance, rather than VyOS config path. Also, apply some minor code cleanup and make some of the mappings consistent across the functions.
2025-01-12kea: T7041: Check lease hostname string is not emptysarthurdev
2025-01-08op-mode: T5992: show dhcpv6 leases with (mostly) the same fields and orderNicolas Vandamme
2025-01-08op-mode: T5992: show dhcpv6 leases with (mostly) the same fields and orderNicolas Vandamme
2025-01-07T6998: dhcp: fix depracted utcfromtimestamp usageErkki Eilonen
Deprecated as per https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp Fixes: TypeError: can't subtract offset-naive and offset-aware datetimes Co-authored-by: Erkki Eilonen <erkki@bearmetal.eu>
2024-12-23op-mode: T5992: fix Kea DHCP server lease outputNicolas Vandamme
2024-07-17op-mode: T6586: add a distinct exception for unconfigured objectsDaniil Baturin
as opposed to entire subsystems
2024-06-27op-mode: T6524: rewrite "release dhcp(v6) interface" to new op-mode formatChristian Breunig
2024-03-28dhcp: T6174: Add TACACS/Radius users to _kea groupsarthurdev
Also raise op-mode error when unable to fetch data from Kea socket
2024-03-28op-mode: T6175: "renew dhcp interface <name>" does not check for DHCP interfaceChristian Breunig
The current op-mode script simply calls sudo systemctl restart "dhclient@$4.service" with no additional information about a client interface at all. This results in useless dhclient processes root 47812 4.7 0.0 5848 3584 ? Ss 00:30 0:00 /sbin/dhclient -4 -d root 48121 0.0 0.0 4188 3072 ? S 00:30 0:00 \_ /bin/sh /sbin/dhclient-script root 48148 50.0 0.2 18776 11264 ? R 00:30 0:00 \_ python3 - Which also assign client leases to all local interfaces, if we receive one valid DHCPOFFER vyos@vyos:~$ show interfaces Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down Interface IP Address MAC VRF MTU S/L Description ----------- ----------------- ----------------- ------- ----- ----- ------------- eth0 - 00:50:56:bf:c5:6d default 1500 u/u eth0.10 172.16.33.102/24 00:50:56:bf:c5:6d default 1500 u/u eth1 172.16.33.131/24 00:50:56:b3:38:c5 default 1500 u/u 172.16.33.102/24 and 172.16.33.131/24 are stray DHCP addresses. This commit moved the renew command to the DHCP op-mode script to properly validate if the interface we request a renew for, has actually a dhcp address configured. In additional this exposes the renew feature to the API.
2024-03-06dhcp: T6102: Fix clear DHCP lease op-modesarthurdev
* Add `clear dhcpv6-server lease` * Standardize using vyos.opmode
2024-02-13dhcp: dhcpv6: T3316: Add op-mode for showing DHCP(v6) static-mappingssarthurdev
2024-02-13dhcpv6-server: T3316: Display delegated prefix length in lease outputsarthurdev
2024-02-13dhcpv6-server: T5992: Fix op-mode Kea DHCP lease outputsarthurdev
Due to Kea's lease file cleanup, the CSV file content is inconsistent. This commit makes changes to use the Kea control socket to fetch current lease information.
2024-01-13dhcpv6: T3316: Move options to separate node and extend scopessarthurdev
* Also migrate `address-range` to `range` tag node for consistency with dhcpv4 server syntax
2023-12-29dhcp: T3316: Adjust kea lease files' location and permissionsIndrajit Raychaudhuri
Move the kea lease file to a separate directory `/config/dhcp` that `kea` process can write to so that subprocesses spawned by `kea` process can operate on the lease files. To allow `kea` process to write to `/config/dhcp`, add `_kea` user to `vyattacfg` group. And the lease files are owned completely by `_kea` user to play well with `kea-lfc` process. Specifically, this is necessary for `kea-lfc` which is spawned by `kea` process to clean up expired leases. Since `kea-lfc` creates additional backup lease files, it needs write access to the lease file directory. Additionally, change the extension of the lease file from `.leases` to `.csv` to reflect the actual file format.
2023-12-12dhcp: T3316: Fix dhcp op-mode state 'all' matchingsarthurdev
2023-12-12dhcp: T3316: Fix raw op-mode lease outputsarthurdev
2023-12-08dhcp: T3316: Migrate dhcp/dhcpv6 server to Keasarthurdev
2023-11-30T5778: dhcp server: fix op-mode command <show dhcp server leases ...>.Nicolas Fort
2023-11-27T5778: dhcp server: patch op-mode command <show dhcp server leases>. If ↵Nicolas Fort
*pool* empty, this means that lease was granted by fail-over server. Also fix issue that <show dhcp server leases state all> print nothing.
2023-09-01T5536: Fix show dhcp client leasesViacheslav Hletenko
Fix helpers was moved to vyos.utils package Fix empty new address from the lease file causes OSError: illegal IP address string passed to inet_pton
2023-08-05T3355: provide VRF for DHCP client leasesChristian Breunig
2023-08-04dhcp: T5428: provide common direcotry path via vyos.defaults.directoriesChristian Breunig
Multiple scripts use the same hardcoded path for DHCP client leases in different direcotries - this can't be worse.
2023-07-30T3355: always work with UNIX timestamps for dhcp client lease displayChristian Breunig
ISC dhcp client contains least_update timestamp in human readable format this makes less sense for an API and also the expiry timestamp is provided in UNIX time. Convert string (e.g. Sun Jul 30 18:13:44 CEST 2023) to UNIX time (1690733624) vyos@vyos:~$ ${vyos_op_scripts_dir}/dhcp.py show_client_leases --family inet --interface eth0.10 Interface eth0.10 IP address 172.16.33.123 [Active] Subnet Mask 255.255.255.0 Domain Name vyos.net Router 172.16.33.254 Name Server 172.16.254.30 DHCP Server 172.16.33.254 DHCP Server 86400 Last Update Sun Jul 30 18:13:44 CEST 2023 Expiry Mon Jul 31 18:13:43 CEST 2023 vyos@vyos:~$ ${vyos_op_scripts_dir}/dhcp.py show_client_leases --family inet --interface eth0.10 --raw [ { "last_update": 1690733624, "reason": "RENEW", "interface": "eth0.10", "new_expiry": "1690820023", "new_dhcp_lease_time": "86400", "medium": "", "alias_ip_address": "", "new_ip_address": "172.16.33.123", "new_broadcast_address": "172.16.33.255", "new_subnet_mask": "255.255.255.0", "new_domain_name": "vyos.net", "new_network_number": "172.16.33.0", "new_domain_name_servers": "172.16.254.30", "new_routers": "172.16.33.254", "new_static_routes": "", "new_dhcp_server_identifier": "172.16.33.254", "new_dhcp_message_type": "5", "old_ip_address": "172.16.33.123", "old_subnet_mask": "255.255.255.0", "old_domain_name": "vyos.net", "old_domain_name_servers": "172.16.254.30", "old_routers": "172.16.33.254", "old_static_routes": "" } ]
2023-07-29T3355: migrate "show dhcp client lease" to new op-mode styleChristian Breunig
vyos@vyos# ${vyos_op_scripts_dir}/dhcp.py show_client_leases --family inet --interface eth0.10 Interface eth0.10 IP address 172.16.33.123 [Active] Subnet Mask 255.255.255.0 Domain Name vyos.net Router 172.16.33.254 Name Server 172.16.254.30 DHCP Server 172.16.33.254 DHCP Server 86400 Last Update Sat Jul 29 21:13:32 CEST 2023 Expiry Sun Jul 30 21:13:31 CEST 2023 vyos@vyos# ${vyos_op_scripts_dir}/dhcp.py show_client_leases --family inet --interface eth0.10 --raw [ { "last_update": "Sat Jul 29 21:13:32 CEST 2023", "reason": "BOUND", "interface": "eth0.10", "new_expiry": "1690744411", "new_dhcp_lease_time": "86400", "medium": "", "alias_ip_address": "", "new_ip_address": "172.16.33.123", "new_broadcast_address": "172.16.33.255", "new_subnet_mask": "255.255.255.0", "new_domain_name": "vyos.net", "new_network_number": "172.16.33.0", "new_domain_name_servers": "172.16.254.30", "new_routers": "172.16.33.254", "new_static_routes": "", "new_dhcp_server_identifier": "172.16.33.254", "new_dhcp_message_type": "5", "old_ip_address": "", "old_subnet_mask": "", "old_domain_name": "", "old_domain_name_servers": "", "old_routers": "", "old_static_routes": "" } ]