dhcplibvirtdnsmasq

How to change libvirt DHCP lease time


I use QEMU KVM on my Ubuntu 16.04 server for managing virtual machines connected via both bridge and NAT. I find that a VM connected via NAT requests DHCP request about every 20~25 minutes, and I want to change the DHCP lease (or request?) time longer.

The system log of the host machine is like this:

Oct 28 20:35:33 ubuntu dnsmasq-dhcp[1921]: DHCPREQUEST(virbr0) 192.168.122.174 52:54:00:8e:4d:a2
Oct 28 20:35:33 ubuntu dnsmasq-dhcp[1921]: DHCPACK(virbr0) 192.168.122.174 52:54:00:8e:4d:a2 cdsn-ns3-1
Oct 28 21:02:20 ubuntu dnsmasq-dhcp[1921]: DHCPREQUEST(virbr0) 192.168.122.174 52:54:00:8e:4d:a2
Oct 28 21:02:20 ubuntu dnsmasq-dhcp[1921]: DHCPACK(virbr0) 192.168.122.174 52:54:00:8e:4d:a2 cdsn-ns3-1
Oct 28 21:26:11 ubuntu dnsmasq-dhcp[1921]: DHCPREQUEST(virbr0) 192.168.122.174 52:54:00:8e:4d:a2
Oct 28 21:26:11 ubuntu dnsmasq-dhcp[1921]: DHCPACK(virbr0) 192.168.122.174 52:54:00:8e:4d:a2 cdsn-ns3-1
Oct 28 21:51:40 ubuntu dnsmasq-dhcp[1921]: DHCPREQUEST(virbr0) 192.168.122.174 52:54:00:8e:4d:a2
Oct 28 21:51:40 ubuntu dnsmasq-dhcp[1921]: DHCPACK(virbr0) 192.168.122.174 52:54:00:8e:4d:a2 cdsn-ns3-1
Oct 28 22:13:01 ubuntu dnsmasq-dhcp[1921]: DHCPREQUEST(virbr0) 192.168.122.174 52:54:00:8e:4d:a2
Oct 28 22:13:01 ubuntu dnsmasq-dhcp[1921]: DHCPACK(virbr0) 192.168.122.174 52:54:00:8e:4d:a2 cdsn-ns3-1
Oct 28 22:37:49 ubuntu dnsmasq-dhcp[1921]: DHCPREQUEST(virbr0) 192.168.122.174 52:54:00:8e:4d:a2
Oct 28 22:37:49 ubuntu dnsmasq-dhcp[1921]: DHCPACK(virbr0) 192.168.122.174 52:54:00:8e:4d:a2 cdsn-ns3-1

If libvirt would use something like isc-dhcp-server, I could manually set up the lease time, but I don't know where and how to change it for libvirt. Strangely, a status file "/var/lib/libvirt/dnsmasqvirbr0.status" has a "expiry-time" field with a timestamp which is more than 1 hour away from the current time.

Why does the host machine shows DHCPREQUEST and DHCPACK so frequently? How can I change such frequent request interval?


Solution

  • It is not currently possible to configure the DHCP lease time for libvirt managed dnsmasq.

    There are work in progress patches to add this feature though

    https://www.redhat.com/archives/libvir-list/2016-October/msg00561.html

    which will hopefully get into a release soon.