[pve-devel] [PATCH pve-network] dnsmasq: configure static range for each subnet
DERUMIER, Alexandre
alexandre.derumier at groupe-cyllene.com
Wed Nov 15 21:50:52 CET 2023
>>
>>I have a similar solution for the dhcp-range.
>>I played around with adding and removing IPs from IPAM and It looks
>>like
>>dnsmasq is offering the correct IP, as stored in IPAM and ethers
>>file.
>>
>>I tried with a regular reboot to get a new IP.
>>
>>What I saw when testing with the previous dhcp-range config.
>>VM with an IP in IPAM, manually remove IP from ethers file,
>>the VM will still get an IP in the range, but not the one originally
>>offered.
>>If dnsmasq never saw the MAC, it will not offer an IP.
>>
>>If you find a specific scenario that does not work, please post a
>>step
>>by step description so I can try to reproduce and to get a better
>>understanding of the dnsmasq config.
I can reproduce easily 100%:
- create a nic with mac:xx:xx:xx:xY ip: 192.168.0.10
- start vm. (the ether file is filed + reload)
- the guest do a dhcp request, the dnsmasq respond a store the lease
in /var/lib/misc/zone.lease
- delete the nic
- add a new nic in same vm or another vm, free found ip is
192.168.0.10 (because it was removed)
- start the vm (the ether file is upgrade with the new ip mac + reload)
- the guest do a dhcp request: the dnsmasq can't respond (with my last
patch) or give a dynamic ip in the range (with current implementation)
because it's still see his lease file the old mac:ip assocation
so, the solution is to remove lease file and restart dnsmasq
others dhcp daemons:
KEA
----
With kea, it possible to update/del/add lease directly through unix
socket. (but not static reservation, it's a commercial plugin).
That mean that if an unknown client is doing a request, it can return a
lease in the pool range (and we don't known it, and could allocate it)
echo '{ "command": "lease4-get-all" }' | socat /run/kea/kea4-ctrl-
socket -,ignoreeof
echo '{ "command": "lease4-del", "arguments": {"ip-address":
"192.168.2.20"} }' | socat /run/kea/kea4-ctrl-socket -,ignoreeof
echo '{ "command": "lease4-add", "arguments": {"ip-address":
"192.168.2.20", "hw-address": "1a:1b:1c:1d:1e:1f"} }' | socat
/run/kea/kea4-ctrl-socket -,ignoreeof
echo '{ "command": "lease4-update", "arguments": {"ip-address":
"192.168.2.20", "hw-address": "1a:1b:1c:1d:1e:1f"} }' | socat
/run/kea/kea4-ctrl-socket -,ignoreeof
FREERADIUS
----------
freeradius seem interesting, as it's possible to do custom
plugins,including perl
https://serverfault.com/questions/1098827/freeradius-with-dhcp-server-calls-to-perl-module-returns-error
So, maybe it could be possible to read directly the macs.db database in
/etc/pve dynamically.
I need to read the doc to see how it's works
What we need is just a stupid daemon replying to dhcp request with dhcp
offers using static mac:ip (with correct dhcp protocol implementation
Maybe some pure perl daemon exist ?
or python like https://github.com/flan/staticdhcpd ?
More information about the pve-devel
mailing list