Asus RT-N16 - lost all settings!

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


Joined: 17 Jun 2006
Posts: 837

PostPosted: Sun Jan 16, 2011 10:11    Post subject: Asus RT-N16 - lost all settings! Reply with quote
My router suddenly and inexplicably lost all it's settings. When looking in the GUI all setting was as factory default. Fortunately I have the backup/restore scripts so easy to get all settings back. But this has never happened before.
Has anyone else had this problem?
Sponsor
kt_haddock
DD-WRT Guru


Joined: 25 Dec 2009
Posts: 710

PostPosted: Sun Jan 16, 2011 10:19    Post subject: Reply with quote
I also have rt-n16 but never expect that. Which build do you use ?
_________________
[I prefer answere in whole sentence]
wabe
DD-WRT Guru


Joined: 17 Jun 2006
Posts: 837

PostPosted: Sun Jan 16, 2011 14:11    Post subject: Reply with quote
kt_haddock wrote:
Which build do you use ?

Brainslayer 15778 Mega
barryware
DD-WRT Guru


Joined: 26 Jan 2008
Posts: 13049
Location: Behind The Reset Button

PostPosted: Sun Jan 16, 2011 14:21    Post subject: Reply with quote
Keep an eye on your free nvram. If it fills up, sometimes the router crashes, sometimes it resets.
_________________
[Moderator Deleted] Shocked
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jan 16, 2011 15:27    Post subject: Re: Asus RT-N16 - lost all settings! Reply with quote
wabe wrote:
My router suddenly and inexplicably lost all it's settings. When looking in the GUI all setting was as factory default. Fortunately I have the backup/restore scripts so easy to get all settings back. But this has never happened before.
Has anyone else had this problem?

It's even quite likely to happen if you flash your rom without doing a factory reset.

I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.

~# cat /opt/etc/init.d/S00factdefault
Code:
#!/bin/sh
NAME=factconfig
NAME="$0"
[ -h "${NAME}" ] && NAME="`readlink "${NAME}"`"
CUR_DIR="`dirname "${NAME}"`"
restflag="${CUR_DIR}/just_restored"

wl_ssid=`nvram get wl_ssid`
lan_ipaddr=`nvram get lan_ipaddr`

if [ ! -f "${restflag}" ] && [ "${lan_ipaddr}" = '192.168.1.1' ] && [ "${wl_ssid}" = 'dd-wrt' ] ; then
  optlog $NAME "Detected a firmware reset"
  lastbackup="`ls -1t /opt/var/backups/*.minimal.sh | head -n1`"
  touch "${restflag}"

  if [ -z "${lastbackup}" ] ; then
    optlog $NAME "Unable to find a backup, will restore some handpicked settings"
    nvram set wl_ssid="JP-spot"
    nvram set wl0_ssid="JP-spot"
    nvram set wl_channel="10"
    nvram set wl0_channel="10"
    nvram set wl0_wds1_if="wds0.1"
    nvram set wl0_wds1_hwaddr="00:26:18:A1:3C:98"
    nvram set wl0_wds1_enable="3"
    nvram set wl0_wds1_desc="00:26:18:A1:3C:98"
    nvram set wan_hostname="WAN"
    nvram set wan_domain="mirmana.com"
    nvram set usb_storage="1"
    nvram set usb_usb2="1"
    nvram set usb_mntpoint="opt"
    nvram set usb_automnt="1"
    nvram set sshd_wanport="53022"
    nvram set sshd_enable="1"
    nvram set remote_mgt_ssh="1"
    nvram set remote_management="1"
    nvram set http_wanport="53080"
    nvram set http_passwd="\$1\$yctsdBGX\$va20aPWWw.SBqYeSrbEfk20"
    nvram set lan_ipaddr="192.168.10.1"
    nvram set lan_domain="mirmana.com"

    nvram commit
  else
    optlog $NAME "Restore settings using ${lastbackup}"
    ${lastbackup}
  fi
  optlog $NAME "Reboot"
  reboot
else
  rm -f "${restflag}" 2>/dev/null
fi

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)


Last edited by frater on Sun Jan 16, 2011 16:59; edited 1 time in total
Dark_Shadow
DD-WRT Guru


Joined: 31 Aug 2009
Posts: 2448
Location: Third Rock from the Sun

PostPosted: Sun Jan 16, 2011 15:41    Post subject: Re: Asus RT-N16 - lost all settings! Reply with quote
frater wrote:
I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.
Is this part of OTRW? If so I will update.
_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki
bkmo
DD-WRT User


Joined: 18 Oct 2007
Posts: 385
Location: Grecia, Costa Rica

PostPosted: Sun Jan 16, 2011 16:05    Post subject: Re: Asus RT-N16 - lost all settings! Reply with quote
frater wrote:

I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.

I have a question. I know the script is tailored for your setup and needs to be personally configured for others, but what creates the lastbackup? I have none in /opt/var/backups.

edit: I just did a bit of poking around and found /opt/usr/sbin/backupessential. I suppose you run this via a cron job correct?
wabe
DD-WRT Guru


Joined: 17 Jun 2006
Posts: 837

PostPosted: Sun Jan 16, 2011 16:48    Post subject: Re: Asus RT-N16 - lost all settings! Reply with quote
frater wrote:


I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.



That's a great solution! I don't know all that much about scripting but I assume the code you publish is supposed to go into the file "S00factdefault".

A couple of questions:
- Why do you use the "minimal" version of the the backup and not "essential"? - haven't studied the difference between these two files but always use the essential one when upgrading the ROM

- Do you run this script as a cron job?

- How do you enable usb if the router is in the "factory reset" state - usb is then disabled
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jan 16, 2011 16:58    Post subject: Re: Asus RT-N16 - lost all settings! Reply with quote
Dark_Shadow wrote:
frater wrote:
I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.
Is this part of OTRW? If so I will update.

Just do this...

Code:
wget -O /opt/etc/init.d/S00factdefault http://wd.mirmana.com/S00factdefault
vi /opt/etc/init.d/S00factdefault
chmod +x /opt/etc/init.d/S00factdefault

It isn't fully automatic, unless you have a firmware which has USB enabled by default and automount to /opt.
I asked Kong to publish such a firmware and this is what I have running on my WAN-router.

I wanted to wait until this feature became part of the original DD-WRT (the automount USB), but it seems the devs explicitly don't want that.

The service will be non-executable by default, of course. You also need to put in your own password.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jan 16, 2011 17:06    Post subject: Re: Asus RT-N16 - lost all settings! Reply with quote
wabe wrote:
frater wrote:


I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.



That's a great solution! I don't know all that much about scripting but I assume the code you publish is supposed to go into the file "S00factdefault".

A couple of questions:
- Why do you use the "minimal" version of the the backup and not "essential"? - haven't studied the difference between these two files but always use the essential one when upgrading the ROM

As a safeguard, really.
2 months ago there was a version that would choke on the essential. It may have been that version of the flash. You can run essential afterwards. At least you will have access to your router again.

wabe wrote:
- Do you run this script as a cron job?
Yes, each night at 4. If the backup is the same as the last one, the oldest will get deleted.
Code:
# ls -altr /opt/var/backups/ | tail -n16
drwxr-xr-x 12 root root  4096 Jan 12 00:07 ..
-rwxr-xr-x  1 root root 31697 Jan 13 04:09 90E6BA2EE9F3.01132011.preferred.sh
-rwxr-xr-x  1 root root  9735 Jan 13 04:09 90E6BA2EE9F3.01132011.minimal.sh
-rwxr-xr-x  1 root root 40055 Jan 13 04:09 90E6BA2EE9F3.01132011.essential.sh
-rwxr-xr-x  1 root root  3783 Jan 13 04:09 90E6BA2EE9F3.01132011.dangerous.sh
-rwxr-xr-x  1 root root 43738 Jan 13 04:09 90E6BA2EE9F3.01132011.all.sh
-rwxr-xr-x  1 root root 28393 Jan 14 04:09 90E6BA2EE9F3.01142011.preferred.sh
-rwxr-xr-x  1 root root 36751 Jan 14 04:09 90E6BA2EE9F3.01142011.essential.sh
-rwxr-xr-x  1 root root  3817 Jan 14 04:09 90E6BA2EE9F3.01142011.dangerous.sh
-rwxr-xr-x  1 root root 40468 Jan 14 04:09 90E6BA2EE9F3.01142011.all.sh
-rwxr-xr-x  1 root root 28691 Jan 16 04:09 90E6BA2EE9F3.01162011.preferred.sh
-rwxr-xr-x  1 root root  9628 Jan 16 04:09 90E6BA2EE9F3.01162011.minimal.sh
-rwxr-xr-x  1 root root 37049 Jan 16 04:09 90E6BA2EE9F3.01162011.essential.sh
-rwxr-xr-x  1 root root  3783 Jan 16 04:09 90E6BA2EE9F3.01162011.dangerous.sh
-rwxr-xr-x  1 root root 40732 Jan 16 04:09 90E6BA2EE9F3.01162011.all.sh
drwxr-xr-x  2 root root 32768 Jan 16 04:09 .


wabe wrote:
- How do you enable usb if the router is in the "factory reset" state - usb is then disabled
It's a mod by Kong. The factory reset then has USB enabled and automount to /opt.
http://www.myopenrouter.com/forum/thread/24235/Kong-Mod-Update-build-15758/?page=2

On normal DD-WRT I would need to enable it with my Android phone.


Here I dared to test it (I'm quite #$% if I don't have access to the WAN-router). I just did a factory reset with the webif:
Code:
# grep -B3 -A2 factdefault /opt/var/log/messages
Jan 13 22:11:00 WAN optware.info K90swap: Managing swap partitions
Jan 13 22:11:00 WAN optware.info K90swap: Unmounted swap partition /dev/sda1
Jan 13 22:11:00 WAN optware.info K99optware: Optware shutdown finished
Jan 13 22:12:04 DD-WRT optware.info /opt/etc/init.d/S00factdefault: Detected a firmware reset
Jan 13 22:12:04 DD-WRT optware.info /opt/etc/init.d/S00factdefault: Restore settings using /opt/var/backups/90E6BA2EE9F3.01132011.minimal.sh
Jan 13 22:12:07 DD-WRT optware.info /opt/etc/init.d/S00factdefault: Reboot
Jan 13 22:12:40 WAN optware.info S00optware: Optware startup
Jan 13 22:12:40 WAN optware.info S01addusers: Adding users to /etc/passwd


It had a factory reset at 22:11 and the router was up and running at 22:13. How's that for automagic?

You may have noticed a file that it creates. It will prevent the router to cycle reboots. If that file is there, it will not restore the ROM another time.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
wabe
DD-WRT Guru


Joined: 17 Jun 2006
Posts: 837

PostPosted: Mon Jan 17, 2011 9:39    Post subject: Re: Asus RT-N16 - lost all settings! Reply with quote
frater wrote:

It had a factory reset at 22:11 and the router was up and running at 22:13. How's that for automagic?



I'll try this one out tonight, should be easy to modify the script to suite my environment using the information in the "minimal" restore script. Thanks for the information!

Too bad that at least the standard Big/Mega version of DD-WRT cannot be delivered with USB-support and drive mounting enabled as default.

I'll test the "frater"-version of Kongs Mod which I assume you use.
audi2888
DD-WRT Novice


Joined: 10 Feb 2011
Posts: 1

PostPosted: Thu Feb 10, 2011 10:13    Post subject: Reply with quote
this is a common problem w/ asus routers... i have 2 WL-520Gu and they BOTH forget their settings and restore factory settings...
wabe
DD-WRT Guru


Joined: 17 Jun 2006
Posts: 837

PostPosted: Thu Feb 10, 2011 12:55    Post subject: Reply with quote
I has only happened once to me in more than a years time. Once is one time too much though.

I have implemented Frater's script and also changed to Kongs build which has enable mount USB as default setting in firmware.

Tested by erasing nvram and it indeed works 'automagically'

One obvious problem is that you're stuck with this partical build but as long as no really interesting new features appear I'll stick to this build
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