Michael Ablassmeier
2021-Aug-04 12:12 UTC
Sharing dhcp leases between multiple host systems
hi, assume i have multiple host systems which spin up virtual machines using the vagrant/vagrant-libvirt provider. Both host systems have a defined network (which has the same name on both hosts) which the first network interface of the virtual machine is assigned to. During boot of the virtual machine, the first network device is configured via DHCP and vagrant uses the mac address table or libvirt dhcp leases table to find out about the IP address that was assigned to the virtual machine: From that point on, i can reach the virtual machine locally on the host system. This works nicely if the network is a libvirt NAT network, as the IP addresses are unique on both host systems. Now i want to change the situation and provide routed addresses, thus i want to make sure that an IP that is assigned for a virtual machine on host A is not re-used on host B to not have IP address conflicts. What im searching for is the "libvirt" way to have a central lease file between multiple hosts for the same network (without having another layer like OVS/OVN). What i guess would work is: 1) share /var/lib/libvirt/dnsmasq between both host systems, of course means the virtual bridge for the network has to have the same name on both systems. 2) replace /usr/libexec/libvirt_leaseshelper with my own version, that stores the leases in an central place. 3) a way that exists and i dont know about? Option 2) sounds the best for me, but i currently dont see a way to specify the dhcp-script used for a network on libvirt side .. any opinions on this? Using libvirt 7.x and alike from the centos 8 advanced virtualization stream. thanks, - michael
On 8/4/21 8:12 AM, Michael Ablassmeier wrote:> hi, > > assume i have multiple host systems which spin up virtual machines using > the vagrant/vagrant-libvirt provider. Both host systems have a defined > network (which has the same name on both hosts) which the first network > interface of the virtual machine is assigned to. > > During boot of the virtual machine, the first network device is > configured via DHCP and vagrant uses the mac address table or libvirt > dhcp leases table to find out about the IP address that was assigned to > the virtual machine: From that point on, i can reach the virtual machine > locally on the host system. > > This works nicely if the network is a libvirt NAT network, as the IP > addresses are unique on both host systems. > > Now i want to change the situation and provide routed addresses, thus i > want to make sure that an IP that is assigned for a virtual machine on > host A is not re-used on host B to not have IP address conflicts.If you are using routed networking rather than NAT, then the routed network on each host will have to use a different subnet anyway[*], so there is no chance of any conflict in IP addresses. [*] while you *could* use the same subnet for the routed virtual network on both hosts, each host would then only be able to reach the guests on its own virtual network, and 3rd parties would need to point their routing tables at one host or the other for that single subnet, and so would only be able to reach the guests on one of the hosts, but not the other.> > What im searching for is the "libvirt" way to have a central lease file > between multiple hosts for the same network (without having another > layer like OVS/OVN). > > What i guess would work is: > > 1) share /var/lib/libvirt/dnsmasq between both host systems, of course > means the virtual bridge for the network has to have the same > name on both systems. > > 2) replace /usr/libexec/libvirt_leaseshelper with my own version, that > stores the leases in an central place. > > 3) a way that exists and i dont know about? > > Option 2) sounds the best for me, but i currently dont see a way to > specify the dhcp-script used for a network on libvirt side .. any > opinions on this? > > Using libvirt 7.x and alike from the centos 8 advanced virtualization > stream. > > thanks, > - michael >