> 
> Ah sorry, DHCP leases will not persist across reboots of course. So
> this 
> could work I think.
> 

yes, the vm client will always send a dhcp request if you restart the
vm , or restart the networking service/dhcp client.

the lease timeout is really a decrementing counter in the guest os, to
auto renew/resend a dhcp request on expire.



I have done some tests with kea api,

The host "reservations" can't be done, as it need a database backend
and also it's a non-free plugin.

But, leases can be provided manually without any problem.

(The difference between both, is that with reservations, you don't need
to define a pool/iprange   in the subnet, as they are used for dynamic
ip assign).


So, after vm start, if we find free ip from ipam &&  inject a lease
though kea socket:

echo '{ "command": "lease4-add", "arguments": { "hw-address":
"16:e5:75:c1:28:a0", "ip-address": "192.168.0.101" } }' | socat
UNIX:/var/run/kea/kea4-ctrl-socket -,ignoreeof


The vm will get this ip at boot 

(we just need to be carefull, that if we don't inject any lease, the
dhcp will itself attribute an ip from the pool, I don't think it's
possible to disable this without hacking kea)




The kea config simply define the subnet && pool:


"Dhcp4": {
     "interfaces-config": {
        "interfaces": ["vnet1"],

    },
     ...
    "hooks-libraries": [
       {
             "library": "/usr/lib/x86_64-linux-
gnu/kea/hooks/libdhcp_lease_cmds.so",
       },
    ],
    "subnet4": [
        {

            "subnet": "192.168.0.0/24",
            "pools": [ { "pool": "192.168.0.20 - 192.168.0.200" } ],
            "option-data": [
                {
                    "name": "routers",
                    "data": "192.168.0.1"
                }
            ],
        }
    }

}

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to