Saturday, January 22, 2011

Tomato firmware configuration

I have the Tomato firmware loaded into my Linksys router (WRT54GL 1.1). I acquired a second router of the same type and thought it'd be nice to duplicate the configuration. (if it breaks down or for whatever reason)
When I tried restoring the configuration, I got the error: "You cannot restore settings to a different router".
So I first needed to check what I had to change in the cfg file...

Source device:
gunzip -c tomato_v128_mDA3159.cfg | tr "\0" "\n" | grep "addr=00:1"
et0macaddr=00:16:B6:DA:31:59
lan_hwaddr=00:16:B6:DA:31:59
wan_hwaddr=00:16:B6:DA:31:5A
wl0_hwaddr=00:16:B6:DA:31:5B

Target device (to be overwritten):
gunzip -c tomato_v128_m4AF795.cfg | tr "\0" "\n" | grep "addr=00:1"
et0macaddr=00:1D:7E:4A:F7:95
lan_hwaddr=00:1D:7E:4A:F7:95
wan_hwaddr=00:1D:7E:4A:F7:96
wl0_hwaddr=00:1D:7E:4A:F7:97

Ah! It might check the MAC address! Let's try changing that...
gunzip -c tomato_v128_mDA3159.cfg | perl -pi -e \
's/addr=00:16:B6:DA:31:59/addr=00:1D:7E:4A:F7:95/g;'\
's/addr=00:16:B6:DA:31:5A/addr=00:1D:7E:4A:F7:96/g;'\
's/addr=00:16:B6:DA:31:5B/addr=00:1D:7E:4A:F7:97/g;'\
| gzip -9 > tomato_v128_copy.cfg
(NB: OS X didn't have a sed command that worked nicely with binary files.)

It restored the modified configuration file!
After resetting the modem and other connections that have the old MAC address in memory, I could connect to the internet again.

Update

When upgrading to a different model router, the configuration files will not match. (it checks
boardtype, boardnum, boardflags and other settings).
In that case, you could also SSH to old router and export the configuration in an easier format:
nvram export --dump > 1.txt
scp 1.txt darkfader@192.168.2.103:~

On the new router, you can them import the edited file.

1 comment:

Unknown said...

How would you do this on a Windows7 PC?