Though these instructions were tested on the DIR-835, they apply to many other router models from Linksys, Netgear, ASUS, and many other brands.
Check if your hardware is supported
First thing to do before buying a router, is to check the list of supported hardware. Specific version numbers are important. Some routers have version A supported, then B unsupported, then C again supported. This is due to manufacturers changing chipsets often.
Get the firmware
You need to know the chipset of your router, which should be listed on OpenWRT's hardware wiki, mentioned above.
If your router is supported, then it will have a stable build, which is at present 12.9. To know if it has a stable version, a daily snapshot, or unsupported, find your device on the wiki. For example, here is the entry for DIR-835, which says that I have to use the daily snapshots, or "the trunk".
You then you go openwrt-ar71xx-generic-dir-835-a1-squashfs-factory.bin.
Note that you should get the "-factory" in the name, which is the one you should use, not the "-sysupgrade" one!
Download this file, and place it on a PC with an Ethernet socket.
Flash the new firmware to the router
Although procedures for specific devices vary, most of them can be flashed from the vendor's web interface.
Before doing this, you need to connect the router directly to your computer using an Ethernet cable. Disable any WiFi adapters on your PC that were enabled. Power on the router. Once your PC is connected to the router, point your browser to:
Then, log-in per the vendor's instructions, and navigate to where you can upgrade the firmware. On a D-Link device, you do this from Tools, then Firmware.
Once the flashing is done, the router will reboot. You need to reconnect your PC to the router again, because the IP address of the router has changed.
Set the password
You need to change the password. To do this use PuTTY on Windows, or telnet on Linux to connect to the router:
Then change the password:
Connect to the internet
If you have not connected the router to the internet, then do so now. This means connecting the cable or DSL modem to the yellow Ethernet socket marked "WAN" on the back of the router, and rebooting.
Administering the router from the command line is possible, but also tedious and requires a lot of reading.
Therefore, we need to install the web administration interface, known as LuCI.
To do this, login to the router via telnet or ssh, then execute these commands:
opkg update opkg install luci
If these complete successfully, then you need to start the web server:
And, we also need to make the web server start automatically when the router is rebooted:
Go to web administration
Once you have done all the above, type the following in your browser:
Then you need to use the password you changed above
Now you can enable WiFi, set an SSID and password, and other tasks ...
Smooth sailing from there ...
Mounting a USB storage device
You can also use a USB storage device for various tasks, e.g. run programs from it to save space in the flash storage of the router itself, or use it for output from certain programs, such as logging daemons, e.g. syslog-ng.
Before you can mount a USB storage device, you have to install the following packages:
opkg update opkg install kmod-usb-storage kmod-scsi-generic block-mount kmod-fs-ext4 kmod-fs-vfat e2fsprogs
If you get any of the errors below, then just reboot the router and the modules will be inserted in the correct order for you.
kmod: failed to insert /lib/modules/3.10.32/sd_mod.ko kmod: failed to insert /lib/modules/3.10.32/ext4.ko kmod: failed to insert /lib/modules/3.10.32/sg.ko
Verify that USB device is properly detected
Go to LuCI, and Verify from Status -> System that there are lines like the following section.
These lines verify that the USB system is working and detected the device:
usb 1-1: new high-speed USB device number 2 using ehci-platform usb-storage 1-1:1.0: USB Mass Storage device detected usbcore: registered new interface driver usb-storage
And these verify that the SCSI subsystem has detected the partitions for the device:
SCSI subsystem initialized scsi0 : usb-storage 1-1:1.0 scsi 0:0:0:0: Direct-Access Kingston DataTraveler 2.0 PMAP PQ: 0 ANSI: 0 CCS sd 0:0:0:0: [sda] 3905536 512-byte logical blocks: (1.99 GB/1.86 GiB) sd 0:0:0:0: [sda] Write Protect is off sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00 sd 0:0:0:0: [sda] No Caching mode page found sd 0:0:0:0: [sda] Assuming drive cache: write through sd 0:0:0:0: [sda] No Caching mode page found sd 0:0:0:0: [sda] Assuming drive cache: write through sda: sda1 sd 0:0:0:0: [sda] No Caching mode page found sd 0:0:0:0: [sda] Assuming drive cache: write through sd 0:0:0:0: [sda] Attached SCSI removable disk
Mounting the USB device on boot
To have the USB device mounted on booting the router, edit the file /etc/config/fstab, and put this in it:
config 'mount' option device '/dev/sda1' option options 'rw,noatime,nodiratime,sync' option enabled_fsck 0 option enabled 1 option fstype 'ext4' option target '/mnt/usb1'
Note that we are using noatime (do not update the access timestamp) and nodiratime (do not update the directory access timestamp), to reduce the I/O on the flash drive.
Then issue the following commands to make the above permanent on every boot.
/etc/init.d/fstab start /etc/init.d/fstab enable
More info in OpenWRT's USB Essentials, USB Storage and partitioning, formatting, and mounting storage devices.