Re: [PATCH] network: Add support for configuring dhcp lease time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 27, 2016 at 09:15:18AM +0530, Nehal J Wani wrote:
> 
> I did another experiment. My network xml limited the range to:
> 
>   <ip address='192.168.123.1' netmask='255.255.255.0'>
>     <dhcp>
>       <range start='192.168.123.2' end='192.168.123.6'/>
>     </dhcp>
>   </ip>
> 
> So, we can safely assume that, if, at any given point of time, there
> are two virtual machines with different mac addresses, connected to
> this network, they should have been leased different IP addresses.
> 
> VM1 is spawned with -net nic,macaddr=52:54:00:69:09:b6 -net bridge,br=virbr1
> 
> VM1 is assigned 192.168.123.4 with lease time of 2 mins.
> 
> Sep 27 08:53:32 lenovo dnsmasq-dhcp[12156]: DHCPDISCOVER(virbr1)
> 52:54:00:69:09:b6
> Sep 27 08:53:32 lenovo dnsmasq-dhcp[12156]: DHCPOFFER(virbr1)
> 192.168.123.4 52:54:00:69:09:b6
> Sep 27 08:53:32 lenovo dnsmasq-dhcp[12156]: DHCPREQUEST(virbr1)
> 192.168.123.4 52:54:00:69:09:b6
> Sep 27 08:53:32 lenovo dnsmasq-dhcp[12156]: DHCPACK(virbr1)
> 192.168.123.4 52:54:00:69:09:b6
> 
> VM1 is paused.
> 
> VM1's lease expires.
> 
> VM2 is spawned with -net nic,macaddr=52:54:00:69:09:b1 -net bridge,br=virbr1
> 
> VM2 is assigned 192.168.123.4 with lease time of 2 mins. :-'(

That is totally valid for dnsmasq todo. Once VM1's lease expires there
is no rule that it must not be given to VM2.

Once VM1 is unpaused it will try to renew its original lease
and will get a NACK from dnsmasq, at which point it will have
to request a new lease and get a different IP address.

There's nothing really special about VMs here either. The same would
happen with physical laptop if you close the lid and re-open it some
time later after your lease expired - any other laptop could have got
your lease in the meantime.

Anyone who cares about VMs having the same IP address after resuming
from suspend *must* configure persistent DHCP mappings for their guests.
Relying on automatic assignment will always fail in the end, may be
not immediately, may be not often, but it *will* fail at some point,
usually at the worst possible time.

Or if you enable the libvirt nss module, then you can avoid needing to
care about specific PI addresses at all and just use the VM names
as a hostname

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]