What's new

Where does Merlin store hostnames/reserved DHCP IP list?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Jack Yaz

Part of the Furniture
Looking to find the store of hostnames/reserved DHCP IPs. Are these written to a file somewhere, or stored in nvram?
 
In addition to the info posted above, you can easily backup your static dhcp leases by piping the output to a textfile and saving that for future use.

Code:
nvram get dhcp_staticlist > dhcp_staticlist.txt

Copy the file that was just created to your USB drive (if any) or to your desktop pc.

Whenever you start fresh and you need to restore the static dhcp leases, just enable manual assignment on the LAN > LAN DHCP page in the UI, next open the text file, copy the contents (everything should be on one line) and run the following commands to restore:

Code:
nvram set dhcp_staticlist="<PASTE_STATIC_LEASES_HERE>"
nvram commit
reboot

After rebooting every device gets assigned the reserved IP. Keep in mind that, if the device had an IP out of the pool assigned prior to restoring, it can take up to a day before it asks the router for a new dhcp lease an gets the reserved IP assigned.
 
Because it can sometimes be difficult entering a very long line without it being truncated you can use this method instead.

As a Notepad++ user (when on my Windows laptop) I don't have any issues with truncated lines, but you're right, this should indeed be a better alternative, but the file must of course be copied back after a fresh install to the current directory on the router before it can be executed.
 
As a Notepad++ user (when on my Windows laptop) I don't have any issues with truncated lines
Another consideration is that the router's input buffer is only 1022 characters, so any line longer than that will be truncated. I currently have 17 entries in my DHCP list which takes up 673 characters in NVRAM.
 
Another consideration is that the router's input buffer is only 1022 characters, so any line longer than that will be truncated. I currently have 17 entries in my DHCP list which takes up 673 characters in NVRAM.

Good to know, wasn't aware of that. I currently have 23 entries in my list, I think... I need to check how much characters it is. By 'input buffer' you mean what's pasted (or typed) in a terminal I assume? Otherwise backup scripts like John's would have an issue with larger sets of static leases as well. I don´t know whether there's a max number of reservations you can assign?
 
Good to know, wasn't aware of that. I currently have 23 entries in my list, I think... I need to check how much characters it is. By 'input buffer' you mean what's pasted (or typed) in a terminal I assume? Otherwise backup scripts like John's would have an issue with larger sets of static leases as well. I don´t know whether there's a max number of reservations you can assign?
The input buffer only applies when trying to manipulate from the command line. If you want to see, create a simple script with an echo "string" command where string is some really long string greater than 1022 characters.

Included in my nvram-save package, is a little script called 'save-mynvram.sh'. If you execute it with the name (or names) of an nvram variable, like
./save-mynvram.sh dhcp_staticlist

it will create a script
restore-mynvram.sh

that will handle restoring the variables (and take care of any special characters, line length, etc). If you want, you could rename it, like
restore-dhcp_staticlist.sh to keep track of what it does.
 
Last edited:
Of interest are also:
Code:
/tmp/var/lib/misc/dnsmasq.leases
/***/hosts.dnsmasq
***=etc*
*) or else this post is blocked by the smart filter.
 
Of interest are also:
Code:
/tmp/var/lib/misc/dnsmasq.leases
/***/hosts.dnsmasq
***=etc*
*) or else this post is blocked by the smart filter.

Also of interest (with same translation :) )
/***/ethers

where the parsed assignments are stored.
 
./save-mynram.sh dhcp_staticlist

@john9527, when trying your script to save single nvram values I noticed a typo in the command above. It should read:

Code:
./save-mynvram.sh dhcp_staticlist

Nevertheless, very useful! Hadn't used that before, so thanks for mentioning it.
 
@john9527 I sure miss using this nvram-save program. I can't use it because it doesn't work well with LetsEncrypt. After restore there is no way to login to the router. I think the port is saved but not the LetsEncrypt cert or something like that.
 
Certificates are stored in JFFS. Make sure you take a backup of your JFFS partition.
 
Another consideration is that the router's input buffer is only 1022 characters, so any line longer than that will be truncated. I currently have 17 entries in my DHCP list which takes up 673 characters in NVRAM.
I moved this list out of nvram by putting the static list into a jffs maintained config file
Code:
admin@RT-N66U-25A0:/jffs/configs# cat dnsmasq.conf.add 
# Appended to dnsmasq.conf automatically, or if done by hand, restart the service with
# $ service restart_dnsmasq
#
# generated from GUI settings via the command
# nvram get dhcp_staticlist | sed 's/</\n/g' | awk -F '>' '/>/ { print "dhcp-host=" $1 ($3 ? ("," $3) : "") "," $2 }' >> /jffs/configs/dnsmasq.conf.add 
#
dhcp-host=00:08:9B:C0:81:5E,homenas,192.168.1.200
dhcp-host=E8:94:F6:EC:3D:11,tplink801-1,192.168.1.100
...

and I then maintain them there (and it's easier for me to backup that file etc).

YMMV... I'm a command-line-and-config-file kind of guy myself :)
 
The dhcp_staticlist.txt technique worked well for me, thanks. But now, is it possible to use a similar file-based save and restore technique for the Rules for routing client traffic through the VPN tunnel?

Update: Found my answer in other messages. Please ignore this question.
 
Last edited:
I am now trying to configure an 86U with 384.8alpha1. I put the dhcp_staticlist.txt file in \jffs\configs, and also the vpn_client1_clientlist.txt. This technique worked for me on 380.7 but is not working on 8alpha1. Do I need to put those files in a different location for 8alpha1 to use them?

Also, is there a similar technique for saving and restoring the WiFi settings for the main and guest accounts for both the 2.4 and 5?
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top