Setting static DHCP lease by command - no internet

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
mooseo
DD-WRT Novice


Joined: 30 Jan 2008
Posts: 11

PostPosted: Thu Feb 25, 2021 7:46    Post subject: Setting static DHCP lease by command - no internet Reply with quote
I'm trying to assign static DHCP leases to some devices on my network.

If I go through the GUI services tab I can assign them and it mostly seems to work.

However, since I had a long list, I'd like to do this by command. Following the instructions here
https://wiki.dd-wrt.com/wiki/index.php/Static_DHCP

nvram set static_leasenum='X';
nvram set static_leases="
MAC1=HOSTNAME1=192.168.1.62=1440
MAC2=HOSTNAME2=192.168.1.63=1440
MAC3=HOSTNAME3=192.168.1.64=1440
MAC4=HOSTNAME4=192.168.1.65=1440 "

This seems to assign them correctly; they do show up in the list on the services tab. However, after I reboot the router and the newly assigned devices, the whole network has no internet. I can still reach the router, but no device can communicate outside. If I delete the static lease assignments everything works again.

It seems pretty similar to what someone experienced in this old thread. However, he seemed to fix the problem by rebooting the device, which I've tried.
https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=726623

I'm running build r45420 on an R7000
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12882
Location: Netherlands

PostPosted: Thu Feb 25, 2021 8:02    Post subject: Reply with quote
Simply add the static leases in the Additional DNSMasq options like:
Code:
dhcp-host=00:012:A8:CD:25:21,QNAP453,192.168.0.91,1440m


So you add them all at once there, no need to use nvram

The problem might be non alphanumeric characters in the hostname, the rules are more strict nowadays.
Use only alphanumeric characters and a simple hyphen (underscore might work)
If you use "wrong" characters DNSMasq does not start

You are posting in the wrong forum

To get the best out of DDWRT and the forum read the forum guidelines with helpful pointers:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087

If you have not already read the forum guidelines, please do !!

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
mooseo
DD-WRT Novice


Joined: 30 Jan 2008
Posts: 11

PostPosted: Fri Feb 26, 2021 16:13    Post subject: Reply with quote
I tried putting the list in additional DNSmasq. A few worked (where I assigned them the same IP they already used) but if I added others, I had the same effect of no internet for anyone, and no DHCP clients listed.

I've checked the list that I pasted from notepad++ and there don't seem to be any characters other than alphanumeric and hyphen.

Deleting the entries in that table restores access.

Also, you mention this is wrong forum for this question; which would be a more appropriate one? The Broadcom forum seems to have lots of question about the R7000
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12882
Location: Netherlands

PostPosted: Fri Feb 26, 2021 16:32    Post subject: Reply with quote
It can be of interest to all so the Advanced Networking is better but no harm done.

Trust me this crops up rather often and invariably it is a typo.
Recently a user was using an o (letter o) instead of the number 0 in the MAC address.

So check by adding one static lease at a time and see which is the offending one

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
mooseo
DD-WRT Novice


Joined: 30 Jan 2008
Posts: 11

PostPosted: Fri Feb 26, 2021 17:27    Post subject: Reply with quote
A typo does seem like a reasonable first thing to check, for sure.

A couple of questions that I haven't been able to find answers to:

Do I need to reboot the router between each addition?

What's the best way to deal with there being devices already granted leases for some of the IP address I'd like to now assign to a different device? I've tried setting a short lease time in hopes that they will all have to renew within an hour to fix any collisions.

Do IP addresses assigned this way need to be within the "Start IP Address" range in network setup? I assume they do, but if they did not have to be, it would provide another option to avoid conflicts.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12882
Location: Netherlands

PostPosted: Fri Feb 26, 2021 17:40    Post subject: Reply with quote
mooseo wrote:
A typo does seem like a reasonable first thing to check, for sure.

A couple of questions that I haven't been able to find answers to:

Do I need to reboot the router between each addition?

What's the best way to deal with there being devices already granted leases for some of the IP address I'd like to now assign to a different device? I've tried setting a short lease time in hopes that they will all have to renew within an hour to fix any collisions.

Do IP addresses assigned this way need to be within the "Start IP Address" range in network setup? I assume they do, but if they did not have to be, it would provide another option to avoid conflicts.


You do not have to reboot just add them one by one in the additional config Save /Apply and check if DNSMasq keeps running with ps from command line like:
Code:
root@R6400v1:~# ps | grep dnsmasq
 1400 root      1840 S    dnsmasq -u root -g root -C /tmp/dnsmasq.conf
 3744 root      1440 S    grep dnsmasq
root@R6400v1:~#


it can take a number of seconds before it restarts so be patient after saving/Apply

Static lease must be *outside* the scope of the DHCP range

For everything there is a wiki unfortunately not all up to date:
https://wiki.dd-wrt.com/wiki/index.php/DNSMasq_as_DHCP_server

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
redhawk0
DD-WRT Guru


Joined: 04 Jan 2007
Posts: 11564
Location: Wherever the wind blows- North America

PostPosted: Fri Feb 26, 2021 18:37    Post subject: Reply with quote
I add static leases in as you do since there are so many in my list.

They need to be outside the DHCP address range as stated earlier.

Try making the list all on the same line. Keeping a space between each of your leases (after the =1440 in your list)....and a space after the last =1440 as well.

example
nvram set static_leasenum=X
nvram set static_leases="MAC1=HOSTNAME1=192.168.1.62=1440 MAC2=HOSTNAME2=192.168.1.63=1440 MAC3=HOSTNAME3=192.168.1.64=1440 MAC4=HOSTNAME4=192.168.1.65=1440 "
nvram commit

In the case above X would be 4...and your DHCP range is not 192.168.1.62-65

I have 22 static leases on my setup working with the above setup. (don't forget the nvram commit or you it might not keep the settings after a reboot.

redhawk

_________________
The only stupid question....is the unasked one.
mooseo
DD-WRT Novice


Joined: 30 Jan 2008
Posts: 11

PostPosted: Sat Feb 27, 2021 8:19    Post subject: SOLVED: Thanks! Reply with quote
Thanks for this advice, it got me working. I think the problem was that I was assigning the static IPs in the DHCP space.

I did also find a typo in my list (using same IP twice), but that one hadn't been deployed to cause issues yet, so that was pre-emptive help.

I am curious, though, about the difference between assigning static IPs using the nvram method or the DNSmasq method. In reading through some posts, I thought the mechanism changed with later builds, but perhaps both work?
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12882
Location: Netherlands

PostPosted: Sat Feb 27, 2021 8:29    Post subject: Reply with quote
When you use the GUI it works via nvram so that is the same method.

What the nvram settings do is adding it to DNSMasq more or less just liked the way I described.

In the end it is just DNSMasq doing the work which uses text based conf files

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Rykazz
DD-WRT Novice


Joined: 09 Feb 2021
Posts: 1

PostPosted: Sat Feb 27, 2021 10:14    Post subject: Reply with quote
Just my 2 cents. But, Is it maybe the space in front of the last quote?
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum