Back in 2009 I purchased a Linksys WRT160Nv2 wireless router for my home. I did not do much homework at the time because I was busy with a new job, a baby, and just wanted to get wireless connectivity at home. I stopped using the device when I moved again in 2012 as Verizon provides me a router device to connect to their FIOS service.
For my home “lab”, if you can even call it that, I am looking to hook up some old devices and machines. At first I was pricing out some small home router/switch combos, but in digging through a box of old equipment, I found the WRT160Nv2, and thought I might be able to repurpose it with OpenWRT, DD-WRT or some other open-source software on the device.
After some initial research, it turns out this router/switch device is a bit of kludge. The WRT160Nv1 and WRT160Nv3 of this series of device had decent hardware, but for WRT160Nv2 it looks like Linksys tried to cut costs by using Ralink chipset and not putting enough memory in the device. As such, both OpenWRT and DD-WRT do not support the hardware. Furthermore, the vendor abandoned the platform and the factory firmware has known vulnerabilities and bugs.
In searching the OpenWRT forums, I uncovered a topic leading to a project on GitHub called OpenWrt Leitec. It is a modified build of the OpenWRT software for Ralink RA2880 routers. The WRT160Nv2 has limited support for this build due to the fact the router only has 16 MB of memory. I am going to give that a try because I don’t plan to use this device as a wireless router, but just as an Ethernet switch. Hopefully I can disable much of that functionality once I get OpenWRT installed on the device!
Building the OpenWRT Firmware
Note to self: Your stupid Windows computer went to sleep, and VMWare Desktop Pro couldn’t handle that and starting thrashing the disk. It took the system 10 minutes to recover after wake-up. Turn off the PC sleep settings and just let the monitor go to sleep!
Building the firmware is rather straightforward. I have a Windows 8.1 desktop computer with VMWare Desktop Pro. Within that I have a simple Linux VM that I used for building the firmware. Note that OpenWRT does not support Windows for building the firmware, one needs Linux, BSD, or Mac OS X. The command sequence is as follows:
mkdir projects; cd projects
git clone https://github.com/leitec/openwrt-leitec.git
The make menuconfig build command brings up a console-based UI for customized the firmware build. One needs to select the RA288x target and subtargets in order to build for the Ralink chipset.
The graphic above shows the target/subtarget already selected, but one would select the Target System option and go into the Target system submenu, shown below.
For the WRT160Nv2, which is based on the RT2880 chipset, select the Ralink RT288x option and return. From the main menu, then go into the Subtarget submenu.
Select the RT288x based boards options and return to the main menu. From the main menu, navigate to the “Exit” option at the bottom of the screen. This will bring up a save prompt as shown below:
Save the configuration and you should be returned to the system shell. From here, one can begin building the OpenWRT firmware. Start the makefile!
The build process begins by compiling all of the tools necessary for the target chipset, such as m4, xz, autoconf, gdb, gcc, et cetera. These tools are needed for cross-compilation for the target platform; the default tools on most systems are for x86_64 based software and not the embedded chipset on the router devices.
I was able to successfull build all of the tools, but during the toolchain build for “toolchain/gcc/final” compile stage, I encoutered build errors. To get the error messages, re-run the build script with the “V=s” option.
make V=s 2>&1 > build_log.txt
There were a few warnings and notes thrown out, but the first error I encountered was as follows:
cnfs.gperf:101:1: error: 'gnu_inline' attribute present on 'libc_name_p'
cnfs.gperf:26:14: error: but not here
A bit of google searching turned up a simple patch one can make to the source code. After modifying the code with that patch, the build process moved along happily. At the end of the build process, in the bin/ramips directory are all of the firmware images.
The firmware file to be flashed to the device is openwrt-ramips-rt288x-wrt160nv2-squashfs-factory-code.bin.
I had not powered on this device for over three years, and after navigating to the admin website (192.168.1.1) after plugging it into my Ethernet port, I released I had forgotten the admin password for the router. Luckily, Linksys makes it easy to reset the router to a default factory configuration.
It should be noted that after flashing the firmware from the proprietary Linksys firmware to the OpenWRT firmware, this option will no longer be available. However, OpenWRT has options for recovery and re-programming with the original factory firmware. In the factory setting, there is no username for the Linksys router webpage, and the password is ‘admin’.
I followed the directions to upgrading firmware from the Linksys website, which essentially tells one to navigate to the Linksys router’s webpage, login, and then navigate to the Administration tab. In the Administration section, select the Firmware Upgrade sub-tab. The resulting webpage is easy to navigate–simply select the OpenWRT .bin firmware image from the build press, and then press the Start Upgrade button.
During my install, the progress bar went to 50%, and then jumped to a page stating that the firmware was successfully written to the device. I was apprehensive at first because I thought there must have been an error, why would it jump to complete at only 50%? Then again, progress bars hugely unreliable indicators of progress with software tasks…
I open up Tera Term and processed to connect to the device at 192.168.1.1 using the telnet protocol…
Success! OpenWRT was installed and is running on the router! To enable ssh, simply setup a root password by running the ‘passwd’ command. After setting a password and logging out, the router is now accessible with ssh and the telnet daemon is disabled. Next I fired up Putty, my preferred Windows SSH client…
Success!!! The router is now ready for configuration of capabilities. It is a good idea to review the limitations of the WRT160Nv2 once more as the limited memory on the router prohibits it from running the web GUI interface as well as software such as OpenVPN.
It is my intention to use this device as a wired router device for now. Perhaps in future I will also look at enabling the 802.11 features too.
My take away from this little project is as follows:
- Always do your homework before purchasing technology, I knew better than just buying something from the store, but I was lazy and just bought the medium grade device from the local store. Now today I have a device that is so crippled that it is hardly supported by open source software.
- Open source software is perfect for re-purposing old hardware and giving it new life after the manufacturer has long abandoned the product.
- Or just make sure you have a lot of money for your technology! I would love to put a Juniper EX2200 in my lab instead, but I don’t have that type of cash to burn on a hobby lab.