Reputation: 13
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?
Upvotes: 1
Views: 3106
Reputation: 604
I believe the accepted answer is no longer correct (i.e. the patch made it through, probably): see this libvirt documentation.
Here's an example from the above documentation of setting leasetime
for an entire range, or a specific host as identified by MAC:
<ip address="192.168.122.1" netmask="255.255.255.0" localPtr="yes">
<dhcp>
<range start="192.168.122.100" end="192.168.122.254">
<lease expiry='1' unit='hours'/>
</range>
<host mac="00:16:3e:77:e2:ed" name="foo.example.com" ip="192.168.122.10">
<lease expiry='30' unit='minutes'/>
</host>
<host mac="00:16:3e:3e:a9:1a" name="bar.example.com" ip="192.168.122.11"/>
</dhcp>
</ip>
Upvotes: 0
Reputation: 2816
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.
Upvotes: 1