What's new

Backup Manual DHCP 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!

Zirescu

Very Senior Member
Is there a way to backup the Manually Assigned IP entries via the command-line? And if so, how? Could I also assume that it could then be restored after doing a factory reset?
 
Is there a way to backup the Manually Assigned IP entries via the command-line? And if so, how? Could I also assume that it could then be restored after doing a factory reset?

Code:
nvram get dhcp_staticlist

Ideally, save the whole nvram to a text file, so you can cherry-pick various settings. Assuming USB disk is mounted as sda1:

Code:
nvram show > /mnt/sda1/settings.txt

To re-enter a setting:
Code:
nvram set dhcp_staticlist="values_previously_saved"
nvram commit
 
Awesome!!

Thanks :) That's super handy to have for other options as well!
 
This should be made sticky.
 
This should be made sticky.

Nah, I don't want to fill up the forums with endless stickies. This should however be cleaned up and posted on the wiki.
 
Code:
nvram get dhcp_staticlist

Ideally, save the whole nvram to a text file, so you can cherry-pick various settings. Assuming USB disk is mounted as sda1:

Code:
nvram show > /mnt/sda1/settings.txt

To re-enter a setting:
Code:
nvram set dhcp_staticlist="values_previously_saved"
nvram commit

Hi Merlin,

I've a USB disk mounted with enough available space but when I tried "nvram show > /mnt/sda1/settings.txt" using the Run Cmd in the N66U router, how come the file is not saved to the disk (I substitute sda1 with FLASH256, that's the volume label of my USB disk). Am I missing anything here? Thanks :)
 
Hi Merlin,

I've a USB disk mounted with enough available space but when I tried "nvram show > /mnt/sda1/settings.txt" using the Run Cmd in the N66U router, how come the file is not saved to the disk (I substitute sda1 with FLASH256, that's the volume label of my USB disk). Am I missing anything here? Thanks :)

Your shares are at directory levels, not at the root. You probably need to save the output to a shared folder on the disk rather than at its root.

Also make sure the disk is really mounted using the label. Best way is to check the mount points:

Code:
mount
 
Your shares are at directory levels, not at the root. You probably need to save the output to a shared folder on the disk rather than at its root.

Also make sure the disk is really mounted using the label. Best way is to check the mount points:

Code:
mount

Thanks Merlin.

Ok, I've create a sub-folder with R/W access and it managed to save the file there but the file size 0 byte.

Code:
nvram show > /mnt/FLASH256/download/settings.txt

I've an external harddisk (OVATION_HD) connected to one of the USB ports and the USB disk (FLASH256) is connected to the other USB port.

Appreciate some pointers, please :)

rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sdb1 on /tmp/mnt/FLASH256 type vfat (rw,nodev,noatime,fmask=0000,dmask=0000,codepage=cp437,iocharset=utf8,shortname=winnt,flush)
/dev/sda1 on /tmp/mnt/OVATION_HD type ufsd (rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,force)
 
I can't think of any reason how the resulting file could end up being 0 bytes long. You are running these commands over SSH or telnet, correct?
 
Oric1, you switched the mount point of FLASH256 from /dev/sda1 (post #7) to /dev/sdb1 (post #9)?
 
I can't think of any reason how the resulting file could end up being 0 bytes long. You are running these commands over SSH or telnet, correct?

I was running the command from "Tools > Run Cmd". Since it can create the file, I shall copy & paste. Thanks for your time :)
 
Oric1, you switched the mount point of FLASH256 from /dev/sda1 (post #7) to /dev/sdb1 (post #9)?

Hi tijaune,

I didn't switched anything. Currently, I've an external HDD connected to one of the USB port & a USB disk to another USB port.
 
Going back to the original poster's question, I have a suggestion.

If you create a file called /jffs/configs/dnsmasq.conf.add with this line:
dhcp-hostsfile=/jffs/etc/dnsmasq/static_leases

Then you can put all your manual DHCP leases into this file /jffs/etc/dnsmasq/static_leases which will survive firmware resets and is easily maintained using nano or vi.

The format of the static_leases file is:
xx:xx:xx:xx:xx:xx,hostname,a.b.c.d,time_to_live

for example:
00:0C:29:41:AA:BB,barney,192.168.0.50,10080m
 
To date, I used the following lines to save/set my dhcp list:
Code:
nvram get dhcp_staticlist > dhcp.txt
nvram set dhcp_staticlist=`cat dhcp.txt`

Going back to the original poster's question, I have a suggestion.

If you create a file called /jffs/configs/dnsmasq.conf.add with this line:
dhcp-hostsfile=/jffs/etc/dnsmasq/static_leases

Then you can put all your manual DHCP leases into this file /jffs/etc/dnsmasq/static_leases which will survive firmware resets and is easily maintained using nano or vi.

The format of the static_leases file is:
xx:xx:xx:xx:xx:xx,hostname,a.b.c.d,time_to_live

for example:
00:0C:29:41:AA:BB,barney,192.168.0.50,10080m

the dnsmasq method looks easier to edit/maintain. Is there other advantage also?

Thanks for sharing it,
 
If you create a file called /jffs/configs/dnsmasq.conf.add with this line:
dhcp-hostsfile=/jffs/etc/dnsmasq/static_leases

Then you can put all your manual DHCP leases into this file /jffs/etc/dnsmasq/static_leases which will survive firmware resets and is easily maintained using nano or vi.

Thanks, this makes it a little more straightforward too. Will be giving this a try shortly, but will attempt to modify it so that it pulls from the SD card instead of the jffs.
 
To: Zirescu

I don't think you can put static_leases file on SD card because the USB thumb drives are not mounted when DNSmasq starts. If you try it, please report back though as it is just my guess.
 
I did not tried the static_leases yet because I do not have jffs activated but according to my log (19:00:11), dnsmasq is starting before USB drive mounting (19:00:12) ...

Code:
Dec 31 19:00:11 dnsmasq[295]: started, version 2.65 cachesize 1500
Dec 31 19:00:11 dnsmasq[295]: compile time options: IPv6 GNU-getopt no-RTC no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack
Dec 31 19:00:11 dnsmasq[295]: asynchronous logging enabled, queue limit is 5 messages
Dec 31 19:00:11 dnsmasq-dhcp[295]: DHCP, IP range 192.168.1.2 -- 192.168.1.254, lease time 1d
Dec 31 19:00:11 dnsmasq[295]: read /etc/hosts - 5 addresses
Dec 31 19:00:11 dnsmasq[295]: read /etc/hosts.dnsmasq - 37 addresses
Dec 31 19:00:11 dnsmasq-dhcp[295]: read /etc/ethers - 37 addresses
Dec 31 19:00:11 WAN Connection: Fail to connect with some issues.
Dec 31 19:00:11 dropbear[299]: Running in background
Dec 31 19:00:11 RT-AC66U: start httpd
Dec 31 19:00:11 crond[308]: crond: crond (busybox 1.20.2) started, log level 8
Dec 31 19:00:11 kernel: scsi 0:0:0:0: Direct-Access     Kingston DT Mini 10       1.00 PQ: 0 ANSI: 2
Dec 31 19:00:11 kernel: sd 0:0:0:0: [sda] 7822288 512-byte hardware sectors (4005 MB)
Dec 31 19:00:11 kernel: sd 0:0:0:0: [sda] Write Protect is off
Dec 31 19:00:11 kernel: sd 0:0:0:0: [sda] Assuming drive cache: write through
Dec 31 19:00:11 kernel: sd 0:0:0:0: [sda] Assuming drive cache: write through
Dec 31 19:00:11 kernel:  sda: sda1
Dec 31 19:00:11 kernel: sd 0:0:0:0: [sda] Attached SCSI removable disk
Dec 31 19:00:11 kernel: sd 0:0:0:0: Attached scsi generic sg0 type 0
Dec 31 19:00:12 hotplug[327]: USB vfat fs at /dev/sda1 mounted on /tmp/mnt/ASUS

However, I don't understand why the dnsmasq lines are coming back again later at 19:00:27 like it was killed due to start_nat_rules on the same reboot. So maybe the static leases file on SD will still be fine because USB is already mounted !? :)

Code:
Dec 31 19:00:27 start_nat_rules: apply the nat_rules(/tmp/nat_rules_ppp0_eth0)!
Dec 31 19:00:27 dnsmasq[295]: exiting on receipt of SIGTERM
Dec 31 19:00:27 FTP Server: daemon is stoped
Dec 31 19:00:27 Samba Server: smb daemon is stoped
Dec 31 19:00:27 dnsmasq[469]: started, version 2.65 cachesize 1500
Dec 31 19:00:27 dnsmasq[469]: compile time options: IPv6 GNU-getopt no-RTC no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack
Dec 31 19:00:27 dnsmasq[469]: asynchronous logging enabled, queue limit is 5 messages
Dec 31 19:00:27 dnsmasq-dhcp[469]: DHCP, IP range 192.168.1.2 -- 192.168.1.254, lease time 1d
Dec 31 19:00:27 dnsmasq[469]: read /etc/hosts - 5 addresses
Dec 31 19:00:27 dnsmasq[469]: read /etc/hosts.dnsmasq - 37 addresses
Dec 31 19:00:27 dnsmasq-dhcp[469]: read /etc/ethers - 37 addresses
 
Yeah, sorry I forgot to post back that I had tried it from the SD card with no luck. I had to load it from JFFS in order to get it to work.

To: Zirescu

I don't think you can put static_leases file on SD card because the USB thumb drives are not mounted when DNSmasq starts. If you try it, please report back though as it is just my guess.
 

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