Linksys WRT54G

This device is great to custom build your own router system. It's cheap, runs Linux with several different firmware distributions available, excellent Broadcom compoments and it's relatively stable/reliable compared to quality commercial products. You can virtually do everything you want with it, i.e. just put on a more powerful version of the stock firmware, increase the signal power output, make it your primary router with 5 VLAN configurable ports (v2 hardware), make it a node in an advanced WDS mesh network, wireless client connected to regular access point, ad-hoc networking, integrated captive portal for wireless hotspots, dedicated lan router and probably a lot more.

List of available firmware distribution:

There are a hole lot of other branded routersa that's based on the Linksys WRT54G, see the list compiled by Seattlewireless users.

There are two main hardware versions, v1 and v2. The major changes are listed below.

v1 hardware
  • 125 MHz MIPS processor
  • 16 MB memory
  • 4 MB flash
  • Bradcom mini-PCI wireless adaptor
  • 3 LED's per port
v1.1 hardware changes
  • No mini-PCI wireless adaptor
  • 1 LED per port
  • Intel flash chip
v2.0 hardware changes
  • 200 MHz MIPS processor
  • (WRT54GS) 32 MB memory
  • (WRT54GS) 8 MB flash
  • POE injectors available
v2.2 hardware changes
  • New Broadcom BCM5325EKQM ethernet controller
  • Single DDR memory chip
  • BGA CPU socket

Buffalo WBR-G54

Data Sheet Manual WBR-G54_2.20_1 firmware

The WBR-G54 has all the expected features but it strengths is the extensive stock syslog logging, packet filtering and alerting capabilities.'

Device information:

It's recognized as v1 hardware, but the vlan configuration (vlan0, vlan1) doesn't seem to come up properly. The DIAG led will light when booting and turns off when the system is loaded.

Default network configuration:

View the kernel dmesg log here.

Linksys WRT54G v2.0

Tutorials:

Data Sheet Manual

The WRT54G is probably the base architecture that of most of the branded routers (Buffalo, Siemens, Belkin, Asus, etc) license and operating systems (OpenWRT, Sveasoft, HyperWRT, etc) support.

Device information:

The unit I got is recognized as v2 hardware, I bought it December 2004. The ethernet controller is eth0 and the wireless controller eth1. And with the new v2 ethernet driver you can independant specify VLAN's, enabling you to either have 5 independant (port0-4) interfaces/vlans or one big switch unit, or a nice combination of both.

The default network configuration:

Port 5 on the switch controller is the internal interface talking to the CPU and detected as eth0. It requires configuration through admcfg and vconfig, and is useless without vlan tagging.

eth0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 3.50.21.10
eth1: Broadcom BCM43XX 802.11 Wireless Controller 3.50.21.10

The DMZ led will light when booting and turns off when the system is loaded.

View the kernel dmesg log here.

Linksys WRT54G v2.2

Tutorials:

Data Sheet Manual

Device information:

This is the second unit I bought to use at home. I got it in mid-April 2005 and it's running OpenWRT experimental. The ethernet controller is eth0 and the wireless controller eth1.

The default network configuration:

Port 5 on the switch controller is the internal interface talking to the CPU and detected as eth0. It requires configuration through admcfg and vconfig, and is useless without vlan tagging.

eth0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 3.60.13.0
eth1: Broadcom BCM4320 802.11 Wireless Controller 3.60.13.0

The DMZ led will light when booting and turns off when the system is loaded.

View the kernel dmesg log here.

OpenWRT Installation

Preparing

On Buffalo units make a copy of the settings using the "Save/Restore" function and take a note of the "System Information" page. You don't need to do a master reset the router to flash it, just use the LAN IP address already assigned when connecting with tftp.

If you have a Linksys WRT54G use the ping.asp exploit to enable the boot_wait setting. On the Buffalo unit I have it was already enabled per default. This will allow you to tftp over a newer firmware at bootup before the operating system is loaded if you experience failure or problems.

To enable the boot_wait on Linksys units, first configure the WAN interface or you'll get a "Network unreachable" error regardless of what you try (Use static 192.168.10.1/255.255.255.0). Then perform the following commands by entering one line and press "Ping" each time.

;cp${IFS}*/*/nvram${IFS}/tmp/n
;*/n${IFS}set${IFS}boot_wait=on
;*/n${IFS}commit

To check the boot_wait parameter enter this line:
;*/n${IFS}show>tmp/ping.log

There's also a second method to trigger the tftp window by shortening two points on the flash chip. Crack open the unit using the disassembling guide and short pin 15 and 16 on the flash memory while powering on the unit. You'll easily see which corner is pin 1 as they're marked 1, 24, 25 and 48. Use a small flat philips screwdriver or similiar to shorten the pins and make sure you don't touch anything else on the circuit board during the procedure. I used a paperclip but anything with a width of 1 mm should do it.

This will trigger a crc mismatch and it will bail out to the tftp server.

Flashing

When the device is booting it first executes the boot loader, PMON, and if boot_wait is set to "on" in the NVRAM it waits a few seconds for incoming tftp downloads before proceeding with the firmware loading. This is called the tftp window. If boot_wait is off it will boot the firmware instantly and you can't upload anything. But if it stumbles accross CRC errors while loading the firmware it will fall back to tftp downloads automatically. You can provoke CRC erros by shortening to data lines on the flash chip as described above.

There are two ways to flash OpenWRT to the device, through the web-based administration or tftp. The latter is more recommended because you learn how to rescue your router if you lock yourself out or something else fails later on.

I chose to use the 'tftp' command-line client on Debian Linux instead of any Windows GUI clients. For me it's just easier and simpler.

If the Linux box isn't on the same network segment yet, add an alias to the NIC. Note the eth0:2 notation, it can be any number after the colon.

ifconfig eth0:2 192.168.50.11 netmask 255.255.255.0

Download snapshot-20041201.tar.bz2 or newer from the daily openwrt snapshot directory and extract the openwrt-linux.trx file for non-Linksys routers and the operwrt-g(s)-code.bin for Linksys routers. Check the main page for any newer version or experimental releases. There are two filesystems, jffs and squashfs. Squashfs is using LZMA compression to make more space available to the user, jffs do not.

tar jxvf snapshot-20041201.tar.bz2

The tftp flashing prodecure is this: start tftp client, set the tfp settings, enter the last put line but don't press enter yet, power off the router, power it on again and hit enter after about 1-2 second. A long transfer log of received and sent messages should fly by if you successfully hit the tftp window, if you didn't try again.

On Buffalo units you can connect to the LAN IP address you assigned with the regular firmware but for Linksys units you have to use the IP address 192.168.1.1. Seems like Buffalo's PMON boot loader is reading the IP address from the NVRAM but not Linksys'.

ivc@server:~$ tftp 192.168.50.1
tftp> binary
tftp> verbose
Verbose mode on.
tftp> trace
Packet tracing on.
tftp> put openwrt-linux.trx
----snip---
received ACK <block=2999>
sent DATA <block=3000, 512 bytes>
----snip---
Sent 1536000 bytes in 2.5 seconds [4915200 bits/sec]

The flash is now complete and the router is rebooting and then initializing the new firmware, shouldn't take more than a few minutes. Do not power off the unit, make sure you can connect to it first.

If you later want to update to a newer OpenWRT firmware you can either use tftp at the boot_wait window or use mtd. Note that mtd expects a TRX file, remove the header to make it a TRX file.

mtd -r write openwrt-brcm-2.4-squashfs.trx linux (you might want to add '-e linux' to erase the device before writing)

You can hardly fit a firmware file on the available flash space so you should use the ramdisk (/tmp) instead. Transfer the file with wget or scp (dropbear).

For Buffalo units you can flash the original firmware back using both of the methods mentioned above, you just have to remove the first 34 bytes from the header make it a true TRX file, i.e. "HDR0" instead of "WBR-B11". Linksys firmwares can be tftp flashed without altering the header but it needs to altered to flash with mtd. Use dd or a hex editor to remove the header.

Note: flashing with tftp will not work with firmwares larger than 3,145,000 bytes in size.

Logging in

Connect with telnet to the LAN IP address assigned before flashing the firmware and you should be dumped to a command-prompt, no login.

telnet 192.168.50.1

Check initializing status

Check if the initializing is finished by checking the read-write status on the root "/" partition. Then it's finished it should be "rw" at the end if the line.

root@OpenWrt:~# mount
---snip---
/dev/mtdblock/4 on / type jffs2 (rw)
---snip---

Now the system is ready to be configured for your liking. Some stock commands that come in handy: route, ifconfig, uptime, top, vi, ps x, df -h, uname -r, nvram, logread.

Filesystem

The root "/" filesystem is basicly built using symbol links to the read-only firmware "/rom" partition. If you want to edit any of the files in the root partition you need to first remove the symbol link and then save the new file to the root partition. If you want to keep the content of the symbol linked file just copy it from the "/rom" partition after removing the symbol link and then edit it with vi. Example:

rm /etc/profile
cp /rom/etc/profile /etc
vi /etc/profile

This file structure us used to save space and to create a failsafe mode. Also note that all files are compressed when they resist on the flash.

Here's a few vi commands.

press "i" - to enter edit/insert mode
escape and ":wq" - to write changes and quit
escape and ":q" - quit un-modified file
escape and ":q!" - to quit without saving
escape and ":<line number>D" - to delete <line number>

Boot hook

You likely want to run or configure various settings upon boot and it's really just to create a file, make it executable and name it so that it executes in the right order. All the scripts resists in the "/etc/init.d" directory.

To add a general hook that executes just before the final S99done script, make a script with a lower sequence number i.e. S90local.

root@OpenWrt:~# vi /etc/init.d/S90local

press "i" and type:
#!/bin/sh

# start daemon
/sbin/daemon &

save and quit:
escape and ":wq"

Make it executable.

chmod 700 /etc/init.d/S90local

Now the script will execute just right before the end of the boot procedure.

Note: Most daemons and server packages include their own boot scripts.

Gateway

I had to add the default gw manually, seems like it didn't pick it up from the nvram gateway_manual parameter. It's probably a Buffalo only parameter.

When setting the wan_gateway parameter in nvram no routing is going through, it works only when it's added 'manually' in a boot script. Add this line to your boot hook (above).

route add default gw xxx.xxx.xxx.xxx eth1 (xxx.xxx.xxx.xxx is your gw)

The extra static routing entry I added through the Buffalo webpage was picked up correctly (static_route).

Static routes

Static routes are handy if you have a large network or use multiple subnets. Upon boot the routes will be grabbed from nvram static_route and put through "route".

nvram set static_route=192.168.11.1:255.255.255.0:0.0.0.0:1:eth0
(the format is: ip address:netmask:gateway:metric:interface)
nvram commit

Name servers

Before you can resolve any domain names and use ipkg with this device you need to set a working DNS server. It would normally be picked up from the wan_dns parameter but Buffalo is using dns_manual0/1 instead. Set the DNS server using the nvram command.

nvram set wan_dns=xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx
nvram commit

You can also configure the regular /etc/resolv.conf file.

root@OpenWrt:~# vi /etc/resolv.conf

press "i" and type:
nameserver xxx.xxx.xxx.xxx [where the xxx's is your preferable dns server]
nameserver xxx.xxx.xxx.xxx

save and quit:
escape + :wq

Hostname

If you want to name the device, set the wan_hostname. The name will show in the command-prompt after the 'at', i.e. root@wbr54g.

nvram set wan_hostname=wbr54g
nvram commit

SSH remote control

It's wise to use a more secure and better way to remote control your router than telnet. Replace telnet with a small package called dropbear, it's a ssh client and server.

Copy the content of /etc/ipkg.conf to /tmp and remove the symbol link as descriped above. Find the latest dropbear version in the official wrt package list. and copy the url string. Paste it into /etc/ipkg.conf and update ipkg list.

root@OpenWrt:~# vi /etc/ipkg.conf

press "i" and paste the url string:
src eviljazz http://www.katastrophos.net/wrt54g/packages

save and quit:
escape and ":wq"

Get the new ipkg package list.

root@OpenWrt:~# ipkg update
Downloading http://openwrt.org/ipkg/Packages ...
Connecting to openwrt.org[208.185.247.160]:80
Packages 100% |*****************************| 15596 00:00 ETA
Done.
Updated list of available packages in /usr/lib/ipkg/lists/openwrt
Downloading http://wrt54g.free.fr/openwrt/b4/ipkg/Packages ...
Connecting to wrt54g.free.fr[212.27.40.157]:80
Packages 100% |*****************************| 6600 00:00 ETA
Done.
Updated list of available packages in /usr/lib/ipkg/lists/_marc_

Install dropbear.

@OpenWrt:/# ipkg install dropbear

Downloading http://openwrt.org/ipkg/./dropbear_0.44test3_mipsel.ipk ...
Connecting to openwrt.org[208.185.247.160]:80
dropbear_0.44test3_m 100% |*****************************| 125 KB 00:00 ETA
Done.
Unpacking dropbear...Done.
Configuring dropbear...
Will output 1024 bit dss secret key to '/etc/dropbear/dropbear_dss_host_key'
Generating key, this may take a while...
Public key portion is:
ssh-dss [REMOVED]
Fingerprint: md5 XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
Changing password for root
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
Enter new password:
Bad password: too simple.

Warning: weak password (continuing).
Re-enter new password:
Password changed.
==========================================
dropbear is now configured to run on boot.
==========================================
To start it now, run the following command:

/usr/bin/dropbear

Done.

Now start dropbear as described and try to connect from another computer. If all went well you can add it to the boot hook or create a new boot script. You can also remove the "/etc/init.d/S50telnet" boot script to disable telnetd from starting.

Other packages and settings

You may want to install a few other packages like iptraf, uptimeclient.

To simplify thing and make it more like my Debian systems I like to add a few aliases.

alias w=uptime
alias ll="ls -lh"

NVRAM

The NVRAM is where the network and some system settings are stored. You can view or edit the parameters using the command nvram.

nvram show - show all
nvram get <parameter> - get specific parameter
nvram set <paramter=value> - edit parameter
nvram commit - save parameters to nvram partition

A small summary of the important parameters can be found here.

There's no regular network config files in "/etc", it's all configured through nvram and/or 'manual' route/ifconfig commands. But most of the parameters are driver specific and not system specific.

Most of the parameters were described pretty well in the stock firmware and it's a good idea to make a complete mirror of the webpages using httrack for Windows or wget for Linux. The nvram parameter for the specific setting can be found in the source code of the webpages, usually after the "name=" tag.

Failsafe

If you locked yourself out or made a configuration error you can load failsafe and only the default OpenWRT firmware will be loaded. The LAN IP address to telnet is 192.168.1.1, regardless of the nvram parameters.

Trigger the failsafe by holding the reset button just after powering on, wait for diag led to light up, release the button after about 10 seconds. Technically the router will wait 1 second after the diag is lite and then check the status of the reset button. If you have boot_wait enabled it will take additional 5 seconds before the diag lights. When the OpenWRT is finished booting the diag led will turn off.

You can do maintaince on th jffs2 user partition by mouting it with these commands.

mtd unlock mtd4
mount -t jffs2 /dev/mtdblock/4 /jffs

Disable Bridge

If you want more secure or want to set up a adhoc network you will need to disable the br0 bridge. Set these parameters and reboot.

nvram set lan_ifname=eth0 (instead of br0)
nvram set lan_ifnames= (empty)
nvram set wifi_ifname=eth2
nvram commit

ifup lan
ifup wifi

You can also disable it with the brctl command.

ifconfig br0 down
brctl delbr br0

Any masqurading between eth0 (LAN) and eth1 (WAN) will not be affected as per "/etc/init.d/S45firewall".

To enable the bridge again just reverse the process.

nvram set lan_ifname=br0
nvram set lan_ifnames=eth0 eth2
nvram unset wifi_ifname
nvram commit

ifup lan
ifup wifi

Or if you prefer the brctl command.

brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth2
ifconfig br0 up
ifup lan

Disable dhcp server

If you already have a dhcp server running on your LAN you probably don't want a second server that messes everything up. Just comment one line in the /etc/dnsmasq.conf file.

root@OpenWrt:~# vi /etc/dnsmasq.conf
press "i" and comment this line:
#dhcp-range=192.168.1.100,192.168.1.250,255.255.255.0,12h

escape + :wq - to save and quit

Reboot or restart the dnsmasq daemon.

killall dnsmasq
dnsmasq

Fix Cron

asd

Wifi Power Output

You can turn up the TX power from the default 28 mW to 84 mW to increase range and signal strength, but it's NOT recommended to set it too high because many report heat problems and it will probably die after a few month. The Ewrt distribution is using 56 mW instead and they've been running stable for 9 months without problems. Try small increases at a time, i.e. 35, 40, 50 mW, and stop when you're satisfied with the signal strength (not more than 56 mW).

Networking

This is a small list how the system and driver automatically recognizes network settings. You can however use just plain old routing and configuration tools like route, ifconfig and wl.

LAN

The IP info on LAN port (vlan) can be configured using these parameters.

nvram set lan_ipaddr=xxx.xxx.xxx.xxx
nvram set lan_netmask=255.255.255.0 (or equal)
nvram set lan_proto=static (can be static or dhcp)
nvram set lan_hwaddr=xx:xx:xx:xx:xx:xx (should be already set)
nvram commit

ifup lan

WAN

Likewise, use these parameters to configure the WAN port.

nvram set wan_ipaddr=xxx.xxx.xxx.xxx
nvram set wan_netmask=255.255.255.0 (or equal)
nvram set wan_proto=static (can be static, dhcp, pppoe and unnum)
nvram set wan_hwaddr=xx:xx:xx:xx:xx:xx (the last octet is usually +1 from the lan hw address)
nvram commit

ifup wan

One or more of the values for the parameters is probably unused by OpenWRT since they're used specially for the stock firmware.

PPPOE - DSL Internet connection

You need to install the pppoecd package and configure the settings below to get a functional DSL connection.

nvram set wan_ifname=ppp0
nvram set wan_proto=pppoe
nvram set pppoe_ifname=vlan1
nvram set ppp_username=<your_username_at_your_isp>
nvram set ppp_passwd=<your_password_at_your_isp>
nvram set ppp_redialperiod=30
nvram set ppp_idletime=5
nvram set wan_mtu=1492

nvram commit

ifup wan

Wifi

You know the drill by now.

nvram set wifi_ifname=eth2 (if's not set after breaking the bridge)
nvram set wifi_ipaddr=xxx.xxx.xxx.xxx
nvram set wifi_netmask=255.255.255.0 (or equal)
nvram set wifi_proto=static (can be static or dhcp)
nvram set wl0_hwaddr=xx:xx:xx:xx:xx:xx (the last octet is usually +1 from the lan hw address)
nvram commit

ifup wifi (set up the ip information)
wlconf eth2 up (load the wireless information, ssid, ap mode, etc)

Setting all the nvram parameters can manually be tough and it might be easier to just flash back to the stock firmware, change the settings, flash back to OpenWRT and the system should recognize the changes. Or you could use more regular Linux configuration tools and put the commands in a startup script.

Also, don't use or set the wl_ nvram parameters, use the wl0_ instead.

Enable wireless function

If you disabled the wireless function in the regular firmware you can enable it again by setting wl_radio to 1. When it's disabled you'll only get "eth2 no wireless extensions." with iwconfig and generally have problems getting anything done with it.

nvram set wl0_radio=1 (1=enable and 0=disable)
nvram commit

wlconf eth2 up

Access Point (Master)

Per default the device is normally set to operate as an access point, but if you've configured it in client or adhoc mode you need revert back.

nvram set wl0_mode=ap (access point mode - master)
nvram set wl0_infra=1 (part of an infrastructure)
nvram set wl0_ssid=MY_WLAN
nvram commit

wlconf eth2 up

If you have problems connecting make sure the access control list paramter is disabled, see below.

The similar iwconfig is this one, might not work that well though.

iwconfig eth2 mode master essid MY_LAN channel 6

Wireless Client (Managed)

This is the most common mode when connecting to a access point as a client.

nvram set wl0_mode=sta (station mode)
nvram set wl0_infra=1 (part of an infrastructure)
nvram set wl0_ssid=MY_WLAN
nvram commit

wlconf eth2 up

The iwconfig command would look like this.

iwconfig eth2 mode managed essid MY_LAN channel 6

Ad-hoc

To only link together two wireless machines, use Ad-hoc. Set the same SSID and IP range on both machines and it should be ready to perform.

You might need to disable the brigde before creating or joining an ad-hoc network, read above.

To join set the following parameters.

nvram set wl0_mode=sta (station mode)
nvram set wl0_infra=0 (not part of an infrastructure)
nvram set wl0_ssid=MY_ADHOC

wlconf eth2 up (reload driver)
wl ap 1 (to clear any old adhoc configuration)
wl ap 0
iwconfig

And to create. Note that there is a problem setting wl0_mode=ap and wl0_infra=0 together to make it discoverable on the other machine, therefore forcing wl to use AP mode seems to work.

nvram set wl0_mode=ap (to clear any old adhoc configuration)
nvram set wl0_infra=1 (to clear any old adhoc configuration)
wlconf eth2 up (reload)

nvram set wl0_mode=sta (station mode)
nvram set wl0_infra=0 (not part of an infrastructure)
nvram set wl0_ssid=MY_ADHOC

wlconf eth2 up (reload driver)
wl ap 1 (make it discoverable)
iwconfig

As a side note, it's possible to do the same configuration with iwconfig but the problems still presist regarding old configurations.

iwconfig eth2 mode ad-hoc essid MY_ADHOC channel 6

Wireless Distribution System (WDS)

WDS is really only a wireless bridge to another access point while simuntaniously serving wireless clients. It can be used to build a grid of access points and route the clients traffic to another access point nearby. This makes it easy to install an access point where no wired connection exists. Two or more access points can create a WDS network.

When adding an access point to a WDS network, a new virtual interface will be created. By setting up the correct routing tables you can send the traffic coming in from the clients through this interface.

WDS notes

WEP

To enable WEP on the access point you need to set a few parameters. I found these on the "ad-lan-wireless_sec_g.htm" page from the stock Buffalo firmware.

nvram set wl_wep=restricted (-1=off, restricted=wep and a few others)
nvram set wl_wep_ascii_select[1-4]=1 (1=ascii and 0=hex)
nvram set wl_key[1-4]=[clear text or hex depending on wep_ascii_select1-4]
nvram set wl_key=[1-4] (sets the primary index of the key used
nvram commit

wlconf eth2 up

Below is a guide to set-up WDS on Kamikaze 8.09.

WPA-PSK TKIP

You can enable WPA when WEP is already running. To disable WPA just set wl0_akm=open and reload. More information about configuration here.

ipkg install nas nvram set wl0_akm=psk // wpa-psk
nvram set wl0_crypto=tkip // tkip encryption, aes doesn't work good with mac os x 10.4
nvram set wl0_wpa_psk=C6C0FA2B9A4F7...63chars...C50B75758CA64
nvram set wl0_auth=0 // open, not shared key
/etc/init.d/S40network restart
/etc/init.d/S41nas psk

Access Control List

On this Buffalo device when the MAC control list is set to "Allow All", the nvram wl0_macmode is "allow". The OpenWRT driver reads this value as "Allow association to stations on the MAC list" and not "Disable MAC address matching". Correct this by changing the nvram parameter.

nvram set wl0_macmode=0
nvram commit

wlconf eth2 up

SSID Broadcast

To turn off SSID broadcasting set wl_closed to 1.

nvram set wl_closed=1 (1=deny and 0=allow)
nvram commit

wlconf eth2 up

Backup

After you've done all the changes you probably want to make a backup in case the file system corrupts or you forget to make a backup when upgrading the firmware.

I like to send the "/etc/ directory, install ipkg packages and a output of nvram over to another Linux server.

cd /
nvram show > /nvram-settings.txt
ipkg list_installed > ipkg-list.txt
scp -rp /etc /ipkg-list.txt /nvram-settings.txt user@server.addr:wrt-backup-dir

Or you can make a tarball in "/tmp", there's enought space sine its RAM not FLASH, and send it over somehow.

cd /tmp
tar zcvf openwrt-backup-2004-12-04.tgz /etc /nvram-settings.txt

VLAN

All the 5 ports on the back of the unit is actually virtually tagged and managed by the ethernet driver and switching chip. Here is how to split them:

old version:
lan interface eth0 (vlan0) - wan interface eth1 (vlan1) - new lan interface vlan2/eth3 (vlan2)
nvram set vlan0ports="1 2 5*"
nvram set vlan0hwname=et0
nvram set vlan1ports="0 5"
nvram set vlan1hwname=et0
nvram set vlan2ports="3 4 5"
nvram set vlan2hwname=et0

new wrt54gl v1.1 version:
#wan - pysical port 5
nvram set vlan1ports="4 5"
nvram set vlan1hwname=et0
#lan - pysical port 1-2
nvram set vlan0ports="2 3 5*"
nvram set vlan0hwname=et0
#lan2 - pysical port 3-4
nvram set vlan2ports="0 1 5*"
nvram set vlan2hwname=et0

ifconfig br0 down
brctl delbr br0

nvram set wan_ifname=vlan1
nvram set wan_ifnames=vlan1
nvram set wan_proto=static
nvram set wan_ipaddr=192.168.222.10
nvram set wan_netmask=255.255.255.0

nvram set lan_ifname=vlan0
nvram set lan_ifnames=vlan0
nvram set lan_proto=static
nvram set lan_ipaddr=192.168.233.1
nvram set lan_netmask=255.255.255.0
nvram set lan_hwaddr=00:18:F8:3C:0D:D0

nvram set lan2_ifname=vlan2
nvram set lan2_ifnames=vlan2
nvram set lan2_proto=static
nvram set lan2_ipaddr=192.168.244.1
nvram set lan2_netmask=255.255.255.0
nvram set lan2_hwaddr=00:18:F8:3C:0D:D9

nvram set wifi_ifname=eth1
nvram set wifi_ifnames=
nvram set wifi_proto=static
nvram set wifi_ipaddr=192.168.255.1
nvram set wifi_netmask=255.255.255.0

ifup wan;ifup lan;ifup lan2;ifup wifi
nvram commit
reboot

X-WRT

X-Wrt is an extended GUI for OpenWRT. It's like DD-WRT but with the OpenWRT back-end. The X-Wrt instllation guide will show a lot of un-necessary details, below is the essential commands needed to install X-Wrt ontop of OpenWRT White Russian 0.9. Currently the WBR-G54 is not compatible with the new OpenWRT Kamikaze releases (interface mess-up), White Russian 0.9 is the latest stable.

  1. SSH into the WRT and make sure internet look-ups work, i.e. ifconfig br0:1 192.168.233.1, route add default gw 192.168.233.1, echo "nameserver 192.168.233.1" > /tmp/resolv.conf.
  2. Add this source to /etc/ipkg.conf: src X-Wrt http://download2.berlios.de/pub/xwrt/packages. Reload by executing ipkg update.
  3. Install the latest stable release of X-Wrt: ipkg install http://ftp.berlios.de/pub/xwrt/webif_latest_stable.ipk
  4. The system will reboot and the new GUI will be available through the web interface, normally http://192.168.1.1

Kamikaze

Kamikaze is the next release after White Russian and one of the noticable changes is the much cleaner config system. No longer all the nvram mess, but real config files in /etc/config and an interface tool called uci to manage the settings quickly.

Setup

Currently there is no good usable Broadcom Wifi driver for kernel 2.6 and Kamikaze for Broadcom based routers (WRT54*, etc) is based on kernel 2.4.

Flash the router through the regular web interface, telnet to 192.168.1.1, type passwd to set a password, type reboot and use a SSH client (ssh, putty, etc) to connect to 192.168.1.1.

Backup

One thing I've learned from previous setups and modifications is that backup of the default settings, and more importantly, working settings is a must.

# Backup CFE (Common Firmware Environment)
dd if=/dev/mtdblock/0| strings > cfe.txt
dd if=/dev/mtdblock/0 of=cfe.bin

# Backup NVRAM settings
dd if=/dev/mtdblock/3| strings > nvram.txt
dd if=/dev/mtdblock/3 of=nvram.bin

Cleaning NVRAM

Not all the NVRAM, actually at all the many, of the settings are needed in Kamikaze. Clean it using a handy script from openwrt.org (look through it first). It will also show the before and after size. Details

cd /tmp
wget http://downloads.openwrt.org/people/kaloz/nvram-clean.sh
chmod a+x /tmp/nvram-clean.sh
/tmp/nvram-clean.sh

Adding SD card storage

It's possible to use the GPIO lines used for the LEDs and front buttons to add a SD card via SPI mode. Only 4 points in additional to power and ground needs to be soldered.

References

#wrt54g IRC LOG [openwrt.org]
Your Source For the WRT54G [wrt54g.com]
HyperWRT [hyperdrive.be]
OpenWRT [openwrt.org]
Community LAN Software [dailywireless.org]
Hacking a Wireless Access Point [pisarsky.com]
LinksysWrt54g Wiki [seattlewireless.net]
frottle - Packet Scheduling [sourceforge.net]
Void Main's Linksys WRT54G Revival Tip [is-a-geek.net]
GettingStartedTips [openwrt.org]
OpenWRT RTFM [openwrt.org]
WBRG54 Thread [openwrt.org]
WBR-G54 Wiki [seattlewireless.net]
AODV on Linksys [ucsb.edu]
Turning WRT54G into a WaFreenet node [penguincare.com.au]
OpenWRT NVRAM [openwrt.org]
Jim Buzbee's Linux on WRT54G [batbox.org]
iwconfig vs wlconf vs wl [openwrt.org]
Advanced Wireless with Linux [sorgonet.com]
Linksys WRT54G on a Steriod Diet [ust.hk]
SIPatH Documentation Wiki [sourceforge.net]

DD-WRT Tutorial Wireless Repeater [wi-fiplanet.com]