R7500v2 Is there a way to save the static DHCP lease table?

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware
Author Message
Format_C
DD-WRT Novice


Joined: 25 Oct 2017
Posts: 29

PostPosted: Thu May 14, 2020 13:44    Post subject: R7500v2 Is there a way to save the static DHCP lease table? Reply with quote
[Solved]

I bought a R7500v2 awhile back (coming from a WNDR4500 ->R6300 ->R6400 -> R7500v2)

So all of my other older router were Netgear but they were all Broadcom devices while the R7500v2 is an Atheros device.

Anyway I have about 25 devices on the static lease table on the "Services" tab.

I usually just take a screen shot and re-enter them manually but I am getting tired of doing that every time I need to do a full reset.

So there has to be a way to export or backup/save the DHCP lease table

I have the "Use NVRAM for client lease DB" box checked so there must be a way to backup just that portion of the NVRAM to a file that I can use to restore my long list of DHCP clients.

Thanks and be nice! manual code entering and Linux commands are not really known to me they are like learning a foreign language. Shocked If you post exactly what I have to enter and where I enter the code I can learn for that. Thanks again


Last edited by Format_C on Sat May 16, 2020 9:38; edited 1 time in total
Sponsor
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Thu May 14, 2020 14:17    Post subject: Reply with quote
I use a file defined in the additional DNSMasq options field.

# Static leases are defined in the following file on the USB stick
# (samba name JFFS2):
conf-file=/jffs/dnsmasq.custom

I made the JFFS thumbstick already years ago and can't tell you if the other stuff on it is relevant to this subject, but the partitions on the thumbstick are mounted by the firmware.
The firmware just reads the dnsmasq.custom from the thumbstick.

I access the thumstick using SMB from my laptop in order to edit the DNSMasq.custom file.

The firmware writes its dnsmasq.leases file to the JFFS partition by virtue of the relevant option on the same GUI page as the additional DNSMasq options.

Here are some lines from my custom file:

# DNSMASQ WILL FAIL if there are leading zeroes in IP addresses,
# or characters other than letters, numbers and hyphens in a device name!!!
# This file is linked using an option in Additional Dnsmasq Options:
# conf-file=/jffs/dnsmasq.custom
# Edit this file (on the JFFS partition of the router) if desired and
# hit Apply Settings on the Services, Services page in the DD-WRT GUI
# (or reboot the router).
#

dhcp-host=B4:B6:86:xx:yy:zz,B4:6B:FC:xx:yy:zz,192.168.5.2,HPxxx,infinite
dhcp-host=60:AB:67:xx:yy:zz,192.168.5.3,Mixxx,infinite

dhcp-host=1C:65:9D:xx:yy:zz,HP-G62,infinite


As you can see, you can list two MAC addresses for one machine, if you like (LAN and WLAN). If you omit the IP-address, DHCP will hand out one after its own choice.

You can also copy-paste the dhcp-host lines from a text file into the additional options field and do away with the thumbdrive.
siege
DD-WRT User


Joined: 23 Dec 2016
Posts: 90

PostPosted: Thu May 14, 2020 15:18    Post subject: Reply with quote
ArjenR49 wrote:
You can also copy-paste the dhcp-host lines from a text file into the additional options field and do away with the thumbdrive.


I did this. I took out all the manual entries in the table on that page and instead had all the entries listed in the additional options field. I had SSH keys on that page that needed to be saved as well, so I just have a text document on my computer with all of that info and if I ever need to do a full reset, I can copy/paste back into those fields.

There is an issue with the UI not displaying the hostnames correctly (at all) if you use this method. There's no functional loss, but I missed not being able to see the hostnames on screen — so much so that I went back to the old way of manually putting them in the table, all 30+ of them.

If that's not a bother for you, the "additional options" route is certainly a good way to go.
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Thu May 14, 2020 15:58    Post subject: Reply with quote
siege wrote:
ArjenR49 wrote:
You can also copy-paste the dhcp-host lines from a text file into the additional options field and do away with the thumbdrive.


There is an issue with the UI not displaying the hostnames correctly (at all) if you use this method.



Possibly this work saving approach has caused just the plain hostnames showing in the Status, LAN, Active Clients list for all active clients.

Active clients from the Static leases list used to have the local domain name attached.

DNSMasq option expand-hosts seems to have no effect except for static leases defined in the GUI.

Hostname.domain works still fine e.g. in an SSH command, though.


Last edited by ArjenR49 on Sat May 16, 2020 7:31; edited 1 time in total
Format_C
DD-WRT Novice


Joined: 25 Oct 2017
Posts: 29

PostPosted: Thu May 14, 2020 16:38    Post subject: Reply with quote
ArjenR49 wrote:
I use a file defined in the additional DNSMasq options field.

# Static leases are defined in the following file on the USB stick
# (samba name JFFS2):
conf-file=/jffs/dnsmasq.custom

I made the JFFS thumbstick already years ago and can't tell you if the other stuff on it is relevant to this subject, but the partitions on the thumbstick are mounted by the firmware.
The firmware just reads the dnsmasq.custom from the thumbstick.

I access the thumstick using SMB from my laptop in order to edit the DNSMasq.custom file.

The firmware writes its dnsmasq.leases file to the JFFS partition by virtue of the relevant option on the same GUI page as the additional DNSMasq options.

Here are some lines from my custom file:

# DNSMASQ WILL FAIL if there are leading zeroes in IP addresses,
# or characters other than letters, numbers and hyphens in a device name!!!
# This file is linked using an option in Additional Dnsmasq Options:
# conf-file=/jffs/dnsmasq.custom
# Edit this file (on the JFFS partition of the router) if desired and
# hit Apply Settings on the Services, Services page in the DD-WRT GUI
# (or reboot the router).
#

dhcp-host=B4:B6:86:xx:yy:zz,B4:6B:FC:xx:yy:zz,192.168.5.2,HPxxx,infinite
dhcp-host=60:AB:67:xx:yy:zz,192.168.5.3,Mixxx,infinite

dhcp-host=1C:65:9D:xx:yy:zz,HP-G62,infinite


As you can see, you can list two MAC addresses for one machine, if you like (LAN and WLAN). If you omit the IP-address, DHCP will hand out one after its own choice.

You can also copy-paste the dhcp-host lines from a text file into the additional options field and do away with the thumbdrive.


OK I like this approach to the issue at hand, but does it actually need a USB flash drive to work?

I have quite a few of them but I don't want to tie up one just for this purpose.

I will if I absolutely need to though. The smallest (capacity not physical size) is 4GB so that should be enough for those files
siege
DD-WRT User


Joined: 23 Dec 2016
Posts: 90

PostPosted: Thu May 14, 2020 16:59    Post subject: Reply with quote
Format_C wrote:
OK I like this approach to the issue at hand, but does it actually need a USB flash drive to work?

Nope. No flash drive is required. You just need to paste in the data in the "additional options" field and it will work.

It's helpful, however, to have this data in a text file somewhere on your computer for ease of editing, copying, and pasting.
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Thu May 14, 2020 17:14    Post subject: Reply with quote
Format_C wrote:
ArjenR49 wrote:

You can also copy-paste the dhcp-host lines from a text file into the additional options field and do away with the thumbdrive.


OK I like this approach to the issue at hand, but does it actually need a USB flash drive to work?

I have quite a few of them but I don't want to tie up one just for this purpose.

I will if I absolutely need to though. The smallest (capacity not physical size) is 4GB so that should be enough for those files


Getting a USB thumbdrive to mount and make it accessible through SMB to other clients, plus making DD-WRT use the JFFS partition on the thumbdrive for storage of leases requires extra work, which may not be immediately obvious and maybe requires trial and error.

Like I wrote, you can copy your dhcp-host options from a text file you type up and paste the lines into the additional dnsmasq options field.
You can edit them in the options field and copy the lines from there back to your (backup) text file, when you're satisfied with the settings.
I would say this is the easiest way out of re-entering everything after a reset to defaults.

There may be some limit on the length of the additional options field. Always be prepared for snags like that.

Of course, all the dhcp-host options will also be in the backup created in the Administration, Backup/Restore page.
Format_C
DD-WRT Novice


Joined: 25 Oct 2017
Posts: 29

PostPosted: Thu May 14, 2020 18:35    Post subject: Reply with quote
OK I just looked at my DHCP static lease table I was wrong about 25 I only 16 of them in use.

Anyway is there a certain format that I have to enter them in the "Additional DHCPd Options" box?

Sorry if I seem dense on this subject coding is not my thing. After I figure this problem out it is on to getting guest networks working (one for each radio band with internet access only and no network access)
siege
DD-WRT User


Joined: 23 Dec 2016
Posts: 90

PostPosted: Thu May 14, 2020 18:48    Post subject: Reply with quote
Format_C wrote:
Anyway is there a certain format that I have to enter them in the "Additional DHCPd Options" box?

Yes, use the format ArjenR49 mentioned above, like this:
Code:
dhcp-host=00:(obscured):97,flight,172.16.22.15,480m
dhcp-host=D4:81:(obscured):5C,tv1,172.16.22.16,infinite
dhcp-host=D4:(obscured):A0,tv2,172.16.22.17,infinite
dhcp-host=40:(obscured):EA:BE,smoker,172.16.22.20,240m


An easy thing for you might be to go in to the router's CLI and type:
Code:
cat /tmp/dnsmasq.conf


You'll see a list of all of DNSMasq's settings, including the current static leases you've defined. Just copy those lines into a text document so you'll have it.
Format_C
DD-WRT Novice


Joined: 25 Oct 2017
Posts: 29

PostPosted: Fri May 15, 2020 22:21    Post subject: Thank You all I figured it out and I got it working! Reply with quote
siege wrote:
Format_C wrote:
Anyway is there a certain format that I have to enter them in the "Additional DHCPd Options" box?

Yes, use the format ArjenR49 mentioned above, like this:
Code:
dhcp-host=00:(obscured):97,flight,172.16.22.15,480m
dhcp-host=D4:81:(obscured):5C,tv1,172.16.22.16,infinite
dhcp-host=D4:(obscured):A0,tv2,172.16.22.17,infinite
dhcp-host=40:(obscured):EA:BE,smoker,172.16.22.20,240m


An easy thing for you might be to go in to the router's CLI and type:
Code:
cat /tmp/dnsmasq.conf


You'll see a list of all of DNSMasq's settings, including the current static leases you've defined. Just copy those lines into a text document so you'll have it.


Thanks,

I wish I asked this question way sooner then I did that was very easy even for a manual code entering dunce like me!. I now have an easy way to back up and edit the static DHCP lease table.

For reference that
"cat /tmp/dnsmasq.conf" is entered without quotes and is to be entered in the "Administration" tab under the "Commands" sub tab.

enter it in the box and then click "Run Commands"

The output will be all of your static DHCP leases and all of your DHCPd and DNSMasq options.

Now on to figuring out how to make guest networks (one for each radio band and no network access only internet access)
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Sat May 16, 2020 7:25    Post subject: Re: Thank You all I figured it out and I got it working! Reply with quote
Format_C wrote:
Now on to figuring out how to make guest networks (one for each radio band and no network access only internet access)


Bear in mind that I use an external DNS server (a Raspberry PI with PI-HOLE and PI-VPN on the main LAN), so my description will not apply literally in every aspect.

First set up a virtual wireless LAN (VLAN), then do the password stuff for it and reboot.
In the Wireless settings set AP isolation.

The rest is done in Setup Networking.

You'll need to 'create bridge' br1 for your first VLAN.

Leave the network configuration (for ath0.1) at its defaults. Especially do not use unbridged. The wiki warns against it and even though it may be old, it seems to be good advice; I had my share of problems when I tried without explicitly setting up a bridge for the VLAN.

Set your desired network address and mask at 'Network Configuration br1' for the newly defined bridge br1. E.g. 192.168.10.1 and 255.255.255.248 for a small VLAN with max. 5 clients in addition to the network address itself.

Next set a DHCP server for the new bridge br1 at the bottom of this page.
Start value 2 and max 5 (-> client's IP will be from 192.168.10.2 to 192.168.10.6).

Then do the 'Assign to bridge' thing for br1 and your new VLAN (e.g. ath0.1) near the top of the page. The Current Bridging Table will reflect the change.

You will have to apply values or reboot at different points to make new options and values show up.

Now check if DNS settings in the GUI and on connected clients are as expected.

In my case I have no DNS settings in Basic settings (all 0.0.0.0) but in Additional DNSMasq options there is a no-resolv option and a server= line advertising the address of my PI-HOLE DNS server to all clients (of both main LAN and WLAN as well as the VLAN).

There is an option for Net Isolation in the 'Network Configuration br1', but I left it disabled for now.
You could experiment with it and check the results from connected clients. The AP isolation may suffice.

IPv6 may not work on the VLAN.
In my case it doesn't whereas on the main LAN/WLAN both IPv6 and DNSSEC work a treat (according to relevant tests). DNSSEC also works on my VLAN's.

I hope this gets you started.


Last edited by ArjenR49 on Sun May 17, 2020 16:53; edited 1 time in total
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12913
Location: Netherlands

PostPosted: Sat May 16, 2020 7:44    Post subject: Reply with quote
@ArjenR49 and @Format_C you are starting a a new and totally unrelated subject which should be discussed in a separate thread in the Advanced networking forum.

So that we can all learn and search these things back Smile

@Format_C please mark this thread as solved if you are happy with it (add [SOLVED] to the header of your first post)

_________________
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
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC 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 cannot attach files in this forum
You cannot download files in this forum