Discussion:
[Dnsmasq-discuss] Dnsmasq fails to offer static lease (IPv4) occasionally
Timo Sigurdsson
2016-01-11 14:44:52 UTC
Permalink
Hi,

I'm using dnsmasq on OpenWrt as my DHCP and DNS server for my home network. I set
up static leases for all my clients which mostly works well, but sometimes
dnsmasq fails to offer the static IPv4 lease to some of my clients. Instead, they
will get a dynamic IP. Now this doesn't happen too often (sometimes it works for
2 weeks without any issue), but it does happen occasionally (sometimes even with 2 clients on the
same day).

Some basic information:
- I first used the OpenWrt configuration interface UCI to set up the static
leases. But after I became aware of the occasional dynamic assignments, I
switched to configuring the static leases via /etc/hosts and /etc/ethers instead.
But that didn't solve it.

- I have a total of 16 static leases defined which covers all my network devices.
I only use static leases for IPv4. The IP range dnsmasq can use is big enough (100 addresses) and all static leases are within that range, of course.

- The clients with which I saw this problem don't have much in common. One is a
wired desktop computer running Windows 7. The other is a wireless MacBook Air
running OS X. The only similarity I find is that these are both clients that are
not running 24/7. They are often shut down and also often go to standby and wake
up from it. I have two servers on the network that are always connected and with
them I haven't observed any false IP assignment yet.

- All clients have only one way to connect to the network. So, there are no
laptops that would sometimes connect wireless and sometimes wired or anything like that.

- I tried different lease times from 2h to 12h with no effect so far.

- Before I started using OpenWrt with dnsmasq, I used a Linksys Router with the
proprietary vendor firmware and had set up the same static leases there, too. I
never observed such an issue with any of these (same) clients, so it shouldn't be caused by the clients themselves.

When a client does not receive the correct static lease, I can see in the logs
that dnsmasq doesn't send a DHCPOFFER after a DHCPDISCOVER. But I don't see why.
I can see, though, that when a client gets a dynamic IP instead of a static one,
dnsmasq refuses to assign the local domain name (hostname.lan) to this client
that is listed in /etc/hosts. So, dnsmasq seems to recognize the client after
all, but fails to offer the static lease. Since I have only seem this problem so
far with clients that often disconnect and reconnect or go to standby and wake up
again, I just assume that it might have to do something with DHCP leases that
haven't expired yet. That's why I tried diffent lease times but so far with no
luck. Another thing I noticed is: When a client get's a dynamic lease and asks for renewal of the lease at some point, dnsmasq will just acknowledge this request rather than assigning the static lease to the client. So unless I force the client to reconnect (and sometimes reboot the router), they will just keep using the dynamic lease.

What ca I do to prevent this from happening? How can I ensure clients will be
served the correct static lease?
In addition, what is a good or recommended lease time for a home network where
clients should keep the same IP address and where there is a mix of wired and
wireless clients?

I had asked this on the OpenWrt forums before, but nobody was able to help me
there. So, I'd really appreciate any insights or hints you might have. Thanks.

Regards,

Timo
Albert ARIBAUD
2016-01-11 16:09:04 UTC
Permalink
Hi Timo,

Le Mon, 11 Jan 2016 15:44:52 +0100 (CET)
Post by Timo Sigurdsson
When a client does not receive the correct static lease, I can see in
the logs that dnsmasq doesn't send a DHCPOFFER after a DHCPDISCOVER.
But I don't see why. I can see, though, that when a client gets a
dynamic IP instead of a static one, dnsmasq refuses to assign the
local domain name (hostname.lan) to this client that is listed
in /etc/hosts. So, dnsmasq seems to recognize the client after all,
but fails to offer the static lease.
The problem of describing some of dnsmasq's log entries is that maybe
some other log entry would explain things but you're not mentioning it.
Can you copy-paste them here all dnsmaq log entries in the log?
Post by Timo Sigurdsson
Regards,
Timo
Amicalement,
--
Albert.
Timo Sigurdsson
2016-01-11 16:53:10 UTC
Permalink
Hi Albert,
Post by Albert ARIBAUD
Hi Timo,
Le Mon, 11 Jan 2016 15:44:52 +0100 (CET)
Post by Timo Sigurdsson
When a client does not receive the correct static lease, I can see in
the logs that dnsmasq doesn't send a DHCPOFFER after a DHCPDISCOVER.
But I don't see why. I can see, though, that when a client gets a
dynamic IP instead of a static one, dnsmasq refuses to assign the
local domain name (hostname.lan) to this client that is listed
in /etc/hosts. So, dnsmasq seems to recognize the client after all,
but fails to offer the static lease.
The problem of describing some of dnsmasq's log entries is that maybe
some other log entry would explain things but you're not mentioning it.
Can you copy-paste them here all dnsmaq log entries in the log?
Oh boy, I just looked at the logs again and I think I found the culprit:
Mon Jan 11 00:08:14 2016 daemon.info dnsmasq[2527]: read /etc/hosts - 16 addresses
Mon Jan 11 00:08:14 2016 daemon.info dnsmasq[2527]: read /tmp/hosts/dhcp - 1 addresses
Mon Jan 11 00:08:14 2016 daemon.info dnsmasq-dhcp[2527]: read /etc/ethers - 0 addresses

For some reason my /etc/ethers file is gone (empty).

I don't know how that happened. But I will recreate it first and see if that solves it. If I stumble over the issue again (with a populated ethers file), I will post again to the mailing list and make sure you get the full logs.

I'm really sorry for the noise!

Regards,

Timo

Timo Sigurdsson
2016-01-11 16:11:42 UTC
Permalink
Sorry, forgot to mention the dnsmasq version is 2.73 (dnsmasq-full 2.73-1) on OpenWrt Chaos Calmer 15.05.
Let me know if I can provide other useful information.

Regards,

Timo
Post by Timo Sigurdsson
Hi,
I'm using dnsmasq on OpenWrt as my DHCP and DNS server for my home network. I set
up static leases for all my clients which mostly works well, but sometimes
dnsmasq fails to offer the static IPv4 lease to some of my clients. Instead, they
will get a dynamic IP. Now this doesn't happen too often (sometimes it works for
2 weeks without any issue), but it does happen occasionally (sometimes even
with 2 clients on the
same day).
- I first used the OpenWrt configuration interface UCI to set up the static
leases. But after I became aware of the occasional dynamic assignments, I
switched to configuring the static leases via /etc/hosts and /etc/ethers instead.
But that didn't solve it.
- I have a total of 16 static leases defined which covers all my network devices.
I only use static leases for IPv4. The IP range dnsmasq can use is big enough
(100 addresses) and all static leases are within that range, of course.
- The clients with which I saw this problem don't have much in common. One is a
wired desktop computer running Windows 7. The other is a wireless MacBook Air
running OS X. The only similarity I find is that these are both clients that are
not running 24/7. They are often shut down and also often go to standby and wake
up from it. I have two servers on the network that are always connected and with
them I haven't observed any false IP assignment yet.
- All clients have only one way to connect to the network. So, there are no
laptops that would sometimes connect wireless and sometimes wired or anything like that.
- I tried different lease times from 2h to 12h with no effect so far.
- Before I started using OpenWrt with dnsmasq, I used a Linksys Router with the
proprietary vendor firmware and had set up the same static leases there, too. I
never observed such an issue with any of these (same) clients, so it shouldn't
be caused by the clients themselves.
When a client does not receive the correct static lease, I can see in the logs
that dnsmasq doesn't send a DHCPOFFER after a DHCPDISCOVER. But I don't see why.
I can see, though, that when a client gets a dynamic IP instead of a static one,
dnsmasq refuses to assign the local domain name (hostname.lan) to this client
that is listed in /etc/hosts. So, dnsmasq seems to recognize the client after
all, but fails to offer the static lease. Since I have only seem this problem so
far with clients that often disconnect and reconnect or go to standby and wake up
again, I just assume that it might have to do something with DHCP leases that
haven't expired yet. That's why I tried diffent lease times but so far with no
luck. Another thing I noticed is: When a client get's a dynamic lease and asks
for renewal of the lease at some point, dnsmasq will just acknowledge this
request rather than assigning the static lease to the client. So unless I force
the client to reconnect (and sometimes reboot the router), they will just keep
using the dynamic lease.
What ca I do to prevent this from happening? How can I ensure clients will be
served the correct static lease?
In addition, what is a good or recommended lease time for a home network where
clients should keep the same IP address and where there is a mix of wired and
wireless clients?
I had asked this on the OpenWrt forums before, but nobody was able to help me
there. So, I'd really appreciate any insights or hints you might have. Thanks.
Regards,
Timo
_______________________________________________
Dnsmasq-discuss mailing list
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Loading...