ip: make DHCP server address pool range configurable
Summary
Introducing a new connection setting options ipv4.shared-dhcp-range
and ipv4.shared-dhcp-lease-time
, which allows you to customize the DHCP range and lease time offered by DHCP server in shared
connection method.
If these options are not specified, the DHCP range will be automatically determined based on the interface address. The range will be selected to be adjacent to the interface address, either before or after it, with preference given to the largest possible range. The range will be adjusted to fill the available address space, except in networks with a prefix length greater than 24, which will be treated as if they have a prefix length of 24. The default lease time is one hour.
Resolves #941 (closed)
Purpose
There is no DHCP range/option control for ipv4.method=shared. This is a quite basic functionality. Also others are missing this feature as mentioned in #941 (closed). This implements approach suggested by @thaller here.
Notes
- NetworkManager does not restart dnsmasq on change of this option.
- UPDATE: This bug is present in current NetworkManager main and affects current options as well, reported: #1627 (closed)
-
UPDATE 2: RESOLVED
✅ This is intended feature. The user is expected to callnmcli device reapply <device>
orsudo nmcli connection up <connection>
to reaplly changes.
- IPv6 is totally missing for now, however this should go there as well and is an open issue #942 already.
- UPDATE: Followup MR to keep the scope of this one manageable.
-
There are some// TODO:
comments when I suspect something shall be moved elsewhere. These are for highlighting these for reviewer, and would be removed.-
UPDATE: I have found some time to explore the codebase and explored if there are not obvious better ways to implement some parts of this change. Instead I have found similar ways to what I did. The case of defines in
src/libnm-core-aux-intern/nm-libnm-core-utils.h
would have alternative in creating new file that I decided to avoid.
-
UPDATE: I have found some time to explore the codebase and explored if there are not obvious better ways to implement some parts of this change. Instead I have found similar ways to what I did. The case of defines in
- Validation functions are possible candidate for unittests but nothing in this part of codebase have them.
Checklist
Please read https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/CONTRIBUTING.md before opening the merge request. In particular, check that:
-
the subject for all commits is concise and explicative -
the message for all commits explains the reason for the change -
the source is properly formatted -
any relevant documentation is up to date -
you have added unit tests if applicable -
the NEWS file is updated when the change deserves to be mentioned, for example for new features, behavior changes, API deprecations, etc.