From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC series pve-network/pve-cluster/qemu-server] DHCP
Date: Mon, 13 Nov 2023 11:04:04 +0100 [thread overview]
Message-ID: <20231113100419.3317478-1-aderumier@odiso.com> (raw)
Here my current work, based on wip2 Stefan Hanreich
Changes:
I have removed dhcp.cfg extra file, and now we can simply define dhcptype in the zone
So, we'll have 1 dhcp server for each zone, could be in different vrf with same subnet reuse.
/etc/pve/sdn/zones.cfg
simple: simpve
dhcp dnsmasq
ipam pve
simple: netbox
dhcp dnsmasq
ipam netbox
/etc/pve/sdn/vnets.cfg
vnet: vnetpve
zone simpve
vnet: vnetbox
zone netbox
/etc/pve/sdn/subnets.cfg
subnet: simple-172.16.0.0-24
vnet netbox
dhcp-range start-address=172.16.0.10,end-address=172.16.0.20
dnszoneprefix odiso.net
gateway 172.16.0.1
subnet: simpve-192.168.2.0-24
vnet vnetpve
dhcp-range start-address=192.168.2.10,end-address=192.168.2.20
dhcp-range start-address=192.168.2.40,end-address=192.168.2.50
gateway 192.168.2.1
subnet: netbox-172.16.0.0-24
vnet vnetbox
gateway 172.16.0.1
dhcp-range start-address=172.16.0.10,end-address=172.16.0.20
subnet: netbox-2a05:71c0::-120
vnet vnetbox
dhcp-range start-address=2a05:71c0::10,end-address=2a05:71c0::20
I have implement netbox plugin to find a new ip in dhcp range (Don't seem possible
with phpipam, but we could define a full range with all ips).
I have splitted the ipam add|del , from the dhcp lease reservation.
The ipam add|del ip is done when creating|deleting vm, or add|del a vm nic
The dhcp reservation is done at vm start.
The delete of dhcp reservation is done at vm destroy.
(This can be easily extend for ephemeral ip)
At vm start, we search ip associated with mac address.
To avoid to call ipam each time, I have implemented an extra macs.db file, with a
mac-ip hash for fast lookup. This cache is populated with adding an ip in ipam (at vm creation, nic add),
it can also be populated at vm_start if mac is not yet cached. (for example, if ip is pre-reserved manually in external ipam)
I have reused/improve my previous ipam code, so ipv6 is supported && dns plugin is also used if defined.
I have only implemented calls in qemu-server for now
pve-network:
Alexandre Derumier (9):
define dhcpplugin in zone
dhcp : add|del_ip_mapping: only add|del dhcp reservervation
vnet|subnet: add_next_free_ip : implement dhcprange ipam search
ipam : add macs.db for fast mac lookup
ipam : add get_ips_from_mac
vnets: rename del|add|update_cidr to ip
vnets: add del_ips_from_mac
ipams : pveplugin: remove del_dhcp_ip
dhcp : dnsmasq: add_mapping: remove old mac,ip before append
src/PVE/API2/Network/SDN/Zones.pm | 1 +
src/PVE/Network/SDN.pm | 4 +-
src/PVE/Network/SDN/Dhcp.pm | 166 ++++++---------------
src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 50 ++++---
src/PVE/Network/SDN/Dhcp/Plugin.pm | 28 +---
src/PVE/Network/SDN/Ipams.pm | 80 +++++++++-
src/PVE/Network/SDN/Ipams/NetboxPlugin.pm | 61 ++++++++
src/PVE/Network/SDN/Ipams/PVEPlugin.pm | 80 +++++-----
src/PVE/Network/SDN/Ipams/PhpIpamPlugin.pm | 29 ++++
src/PVE/Network/SDN/Ipams/Plugin.pm | 13 ++
src/PVE/Network/SDN/SubnetPlugin.pm | 4 -
src/PVE/Network/SDN/Subnets.pm | 37 +++--
src/PVE/Network/SDN/Vnets.pm | 88 ++++++-----
src/PVE/Network/SDN/Zones/SimplePlugin.pm | 7 +-
src/test/run_test_subnets.pl | 8 +-
src/test/run_test_vnets.pl | 4 +-
16 files changed, 393 insertions(+), 267 deletions(-)
pve-cluster:
Alexandre Derumier (1):
add priv/macs.db
src/PVE/Cluster.pm | 1 +
src/pmxcfs/status.c | 1 +
2 files changed, 2 insertions(+)
qemu-server:
Alexandre Derumier (5):
don't remove dhcp mapping on stop
vmnic add|remove : add|del ip in ipam
vm_start : vm-network-scripts: get ip from ipam and add dhcp
reservation
api2: create|restore|clone: add_free_ip
vm_destroy: delete ip from ipam && dhcp
PVE/API2/Qemu.pm | 6 +++
PVE/QemuServer.pm | 72 +++++++++++++++++++++++++++++++
vm-network-scripts/pve-bridge | 4 +-
vm-network-scripts/pve-bridgedown | 19 --------
4 files changed, 81 insertions(+), 20 deletions(-)
--
2.39.2
next reply other threads:[~2023-11-13 10:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-13 10:04 Alexandre Derumier [this message]
2023-11-13 10:04 ` [pve-devel] [RFC pve-cluster 1/1] add priv/macs.db Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 1/9] define dhcpplugin in zone Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC qemu-server 1/5] don't remove dhcp mapping on stop Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 2/9] dhcp : add|del_ip_mapping: only add|del dhcp reservervation Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC qemu-server 2/5] vmnic add|remove : add|del ip in ipam Alexandre Derumier
2023-11-13 16:14 ` Stefan Hanreich
2023-11-13 10:04 ` [pve-devel] [RFC qemu-server 3/5] vm_start : vm-network-scripts: get ip from ipam and add dhcp reservation Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 3/9] vnet|subnet: add_next_free_ip : implement dhcprange ipam search Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC qemu-server 4/5] api2: create|restore|clone: add_free_ip Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 4/9] ipam : add macs.db for fast mac lookup Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 5/9] ipam : add get_ips_from_mac Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC qemu-server 5/5] vm_destroy: delete ip from ipam && dhcp Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 6/9] vnets: rename del|add|update_cidr to ip Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 7/9] vnets: add del_ips_from_mac Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 8/9] ipams : pveplugin: remove del_dhcp_ip Alexandre Derumier
2023-11-13 10:04 ` [pve-devel] [RFC pve-network 9/9] dhcp : dnsmasq: add_mapping: remove old mac, ip before append Alexandre Derumier
2023-11-13 10:35 ` [pve-devel] [RFC series pve-network/pve-cluster/qemu-server] DHCP Stefan Hanreich
2023-11-13 15:44 ` DERUMIER, Alexandre
2023-11-13 16:11 ` Stefan Hanreich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231113100419.3317478-1-aderumier@odiso.com \
--to=aderumier@odiso.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox