Sharing a .cfg between two routers

Discussion in 'Tomato Firmware' started by fyellin, May 28, 2008.

  1. fyellin

    fyellin LI Guru Member

    Tomato will not let me save a configuration on one WRT54GL and then restore it onto another. There are two reasons I want to do this:

    • I have three boxes that I want to set up as WDS repeaters. The configuration for all of them will be identical, except for their hostname and IP address. It would be nice to get the configuration just right on one box, and then just clone it to the others and make the minimal changes.
    • If my AP dies, it would be nice to be able to save its configuration and then be able to restore it quickly on another box. I wouldn't have to re-enter my static DHCP settings or my QOS settings.
    Is there any way of installing a configuration, possibly via the shell rather than the web interface, in which you can say, "Yes, I know this is from a different box, but let me do it anyway."

    Is there any other way to move a configuration from one machine to another, other than taking a screen shot of each web page, and then re-entering it manually?
  2. roadkill

    roadkill Super Moderator Staff Member Member

    restoring config on different router
    nvram restore <filename> [--force] 
    take care with different models this is dangerous and could have unexpected results
    you have to reset mac address to default afterwards to use the feature via the web interface use this in your init script
    ln -sf "/bin/nvram --force" "/tmp/nvram"
    then nvram will be issued with the force parameter automatically and you should be able to restore configuration without the limitation.
  3. fyellin

    fyellin LI Guru Member

    Thanks! That's exactly what I was looking for.
  4. fyellin

    fyellin LI Guru Member

    I decided to bite the bullet and look at the source code to see what's actually going on.

    I now see that the tomato-xxx.cfg is a compressed file. One uncompressed, it is a header, followed by a long list of key=value pairs separated by null. The "restore" feature ensures that the key et0macaddr has the correct mac address.

    So a little of of gzip and emacs hacking means I could "restore" a router to precisely the name, mac addresses, and lan address that I want.
  5. TexasFlood

    TexasFlood Network Guru Member

    Interesting. I'd never thought about it or experimented but just opened a tomato .cfg config backup file with winrar and can see all the setting. Now the acid test, can I make some changes , save, gzip it again and load it on the router.

    *Update - I just ran a quick test changing something minor as a test. I extracted a tomato .cfg backup file with winrar. I discovered winrar will not create gzip files - who knew, never thought to try before, :-D Had to go grab a windows version of gzip to recreate the compressed .cfg file. All I did was change a character in my password (using a hex editor to make sure I didn't change the file size or structure) then restored it. Worked like a charm with no apparent problems. I was worried about a checksum but if this test worked, should be able to change about anything in there. Cool, thanks for posting that. If my main router dies and I have to replace it with a backup, this will make it potentially a lot easier.
  6. TheGIZ

    TheGIZ Network Guru Member


    I posted about this a while ago and was told not to do it.

    So it actually works at command line but don't try it via the GUI interface?

    I was scanning over a thread in seavasoft and it seems to point out that it is OK there.

    So the question is...
    Has someone taken the CFG of one router and put it on another and had no issues from the http GUI?
  7. fyellin

    fyellin LI Guru Member

    Comparing two routers

    I configured two routers identically (except for host name and IP address), and then compared the output from running "nvram show" on each of them. Very few variables seemed to differ between them. Below is what I found:
    • eou_device_id: An alphanumeric string of length 6. Use not known.
    • eou_private_key: A very long hexadecimal string. Use not known.
    • eou_public_key: Another very long hexadecimal string of unknown purpose.
    • et0macaddr: The hardware address of the LAN, as assigned by the manufacturer.
    • http_id: TID followed by 16 hexadecimal digits. Used by the http daemon to ensure that responses it receives are from pages it was sent. Initialized using a random value from /dev/urandom.
    • lan_hwaddr: Actual LAN hardware address. Either et0macaddr or assigned by the user.
    • lan_ipaddr: The user-assigned LAN IP address.
    • router_name: User assigned name for the router.
    • sdram_ncdl: Purpose unknown. Had values 0xFE0008 and 0xFF0009. The router seems to set this to 0 at times of great confusion, but I can't find what it means.
    • sshd_hostkey: Host key generated by the ssh daemon. It is probably safe to share this between machines. It appears that setting this to the empty string will cause the ssh daemon to generate a new host key at startup
    • wan_hostname: User assigned host name
    • wan_hwaddr: Current WAN hardware address (may be user assigned)
    • wl0_hwaddr: Current wireless hardware address (may be user assigned)
    Any information on the eou_* variables and sdram_ncdl would be appreciated.
  8. Toastman

    Toastman Super Moderator Staff Member Member

    Roadkill: That was useful. Thanks!
  9. roadkill

    roadkill Super Moderator Staff Member Member

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice