[Dnsmasq-discuss] [PATCH] Nack requests for unknown leases.

Simon Kelley simon at thekelleys.org.uk
Sun Apr 23 16:46:14 BST 2017


On 20/04/17 10:34, Alin Nastac wrote:
> Hosts that migrate from one network to another could request their
> old IP address which might be already in use by another statically
> configured host. Currently non-authoritative dnsmasq servers will
> ignore such requests, but ISC DHCP client will send discovery packets
> next carrying the same requested IP address and dnsmasq will end up
> allocating a new lease for it without checking first if is already
> used by another host.


When the client sends the discovery packet, dnsmasq will notice that the
requested address is in use by another client, and offer a different
address instead.

Cheers,


Simon.



> ---
>  src/rfc2131.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/src/rfc2131.c b/src/rfc2131.c
> index 6a8f0db..9987745 100644
> --- a/src/rfc2131.c
> +++ b/src/rfc2131.c
> @@ -1141,10 +1141,12 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
>  	  else
>  	    {
>  	      /* INIT-REBOOT */
> -	      if (!lease && !option_bool(OPT_AUTHORITATIVE))
> -		return 0;
> -	      
> -	      if (lease && lease->addr.s_addr != mess->yiaddr.s_addr)
> +	      if (!lease)
> +		{
> +		  if (!option_bool(OPT_AUTHORITATIVE))
> +		    message = _("lease not found");
> +		}
> +	      else if (lease->addr.s_addr != mess->yiaddr.s_addr)
>  		message = _("wrong address");
>  	    }
>  	}
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20170423/75751657/attachment.sig>


More information about the Dnsmasq-discuss mailing list