DHCPNAK no lease left

(Kristian Malvander) #1

I have 1 host which for one or another reason is unable to get an IP address. I have a scope of 30 address between 110-130 and almost every host has an IP reservation outside this scope so there are plenty of free addresses available.

If I don’t reserve the IP for the host i just receive a DHCPNAK
Jun 6 18:34:04 sme10 dnsmasq-dhcp[2540]: DHCPREQUEST(eth0) 192.168.x.110 xx:xx:xx:c7:2f:56
Jun 6 18:34:04 sme10 dnsmasq-dhcp[2540]: DHCPNAK(eth0) 192.168.x.110 xx:xx:xx:c7:2f:56 no leases left

If i make an IP reservation for the host I still get an DHCPNAK
Jun 6 18:53:28 sme10 dnsmasq-dhcp[2540]: DHCPDISCOVER(eth0) xx:xx:xx:c7:2f:56
Jun 6 18:53:28 sme10 dnsmasq-dhcp[2540]: DHCPOFFER(eth0) 192.168.x.105 xx:xx:xx:c7:2f:56
Jun 6 18:53:29 sme10 dnsmasq-dhcp[2540]: DHCPREQUEST(eth0) 192.168.x.105 xx:xx:xx:c7:2f:56
Jun 6 18:53:29 sme10 dnsmasq-dhcp[2540]: DHCPNAK(eth0) 192.168.x.105 xx:xx:xx:c7:2f:56 no leases left

I’m puzzled? Anyone who can give me an hint how to solve this? The client works fine if I set a fixet IP. The problem started when i restarted the dnsmasq service to fix as a workaround to the openvpn bind problem.

(Kristian Malvander) #2

No the problem propagates to other devices and I have 3 more devices who has this problem now. I have restarted the server and dnsmasq to fix the error with DNS.

Any suggestions are appreciated.

(Davide Principi) #3

If dnsmasq is out of reservations, the lease cache should contain them: have a look to the contents of


(Artem Fedai) #4

maybe it is an OpenVPN problem ? Are U push to VPN users DHCP from dnsmasq?

(Kristian Malvander) #5

Sorry for late response. I’m on vacation with very bad wifi. The problem is on the LAN. I’ll check out your suggestion as soon I get wifi back up in our bungalows. I thought it could be the lease but never found out we’re to verify it because I didn’t find it in the dnsmasq confit file. We’re do I have to change the settings for leases so it becomes permanent?

(Alessio Fattorini) #6

aahaha “NethServer on Bungalows” :sailboat: :tent:
Please take a photo and upload it here

(Kristian Malvander) #7

Finally home a possible to check the settings. I have 20 leases in the cache were do i check the settings for how many leases are set in DNSMASQ and were to I change the settings permanently?

(Artem Fedai) #8

For bungalows make leases every 15 min and it would solve your problem!

(Kristian Malvander) #9

I ment were is the DB settings for dhcp max allowed leases or something similar so I can override it? I have both checked db dhcp show and db configuration show dnsmasq and lastly db configuration show but I can’t find a relevant key there to override?

(Artem Fedai) #10

U need to add key DhcpLeaseTime to dnsmasq db , try and say does it works

(Stefano) #11


you have to check in /templates/ tree the relevant fragment and see if it handles such a variable.

if so, then change it via db command

if not, create a custom fragment in /templates-custom/ tree to override

that’s the way NS works

(Stefano) #13


please, when you answer, you’d be verbose…

so, instead of

you’d say

in this way you help @malvank (and others) to find a solution

moreover, a

db configuration show | grep -i dhcplease

would help


(Artem Fedai) #14

now im from phone and have no time to check
db configuration setprop dnsmasq DhcpLeaseTime 3600
signal-event nethserver-dnsmasq-update
could help but no time to check and in
my $lease = $_->prop(‘DhcpLeaseTime’) || ‘86400’;

so i’l make custom templete later

(Stefano) #15

well done, thank you

(Artem Fedai) #16

so @giacomo @filippo_carletti @alefattorini changes to dnsmasq db doesnot work! but why ? is it a bug ?

and solution is one @malvank :
mkdir /etc/e-smith/templates-custom/etc/dnsmasq.conf
cp /etc/e-smith/templates/etc/dnsmasq.conf/30dhcp /etc/e-smith/templates-custom/etc/dnsmasq.conf/30dhcp
edit :
my $lease = $->prop(‘DhcpLeaseTime’) || ‘86400’;
my $lease = $
->prop(‘DhcpLeaseTime’) || ‘900’;

run signal-event nethserver-dnsmasq-update
and be happy !

(Artem Fedai) #18

next solution is :
edit /etc/e-smith/templates-custom/etc/dnsmasq.conf/30dhcp
coment out my $lease = $_->prop(‘DhcpLeaseTime’);
my $lease = $dnsmasq{‘LeaseTime’};
then add value as you need in seconds for lease time
db configuration setprop dnsmasq LeaseTime 900
signal-event nethserver-dnsmasq-update

(Filippo Carletti) #19

I think that the DhcpLeaseTime prop there is a leftover of the times when we had only a range for green. When we added support for dhcp on blue, the prop moved to the dhcp db.
The command would be:
db dhcp setprop eth0 DhcpLeaseTime 6000
(where eth0 is the interface)

I’ve drafted a server-manager panel to adjust a lot of the dhcp options, stay tuned.

(Artem Fedai) #20

And do not forget about transparent proxy by ip of the server :slight_smile:

(Kristian Malvander) #21

@zamboni @Nas Thank you for your assistance and the solution proposal. I looked into the template layout and I start to understand the setup so much better now but still I’m a bit puzzled. First of all I don’t know why your suggestions is on DhcpLeaseTime, I think my problem is more related that the DHCP is not assigning more than 20 IP addresses and therefore I think the correct solution has to be related with the dhcp-lease-max parameter? I suppose the lease time has some effect for the cache but hence it is set to 24h it’s shouldn’t be of to much of an problem for my scenario.

@filippo_carletti I looked into the template layout cat /etc/e-smith/templates/etc/dnsmasq.conf/30dhcp for the dhcp settings and found out that the dhcp-lease-max is set to if ($tot_range_length > 0) { $OUT .= "dhcp-lease-max=$tot_range_length\n"; } so before I make a complete fool out of myself can you or someone else please tell me if IP reserved IP-addresses are counted into the the value of dhcp-lease-max? I hope not but I fear the oposite.

(Artem Fedai) #22

You could check it simply! So when you have Dhcp error, you could count max values of comp in dhcp.lease file and then you could make some desigions! but i have dnsmasq on wifi routers , all work like a charm without problem.
run cat /var/lib/dnsmasq/dnsmasq.leases | wc -l
and tell us :slight_smile: