Quick How To: Installing OpenWRT on the D-Link DIR-835 wireless router

This is a quick how to for installing OpenWRT custom firmware on a D-Link DIR-835 router.

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:

http://192.168.0.1/

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:

telnet 192.168.1.1

Then change the password:

passwd

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.

Install LuCI

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:

/etc/init.d/uhttpd start

And, we also need to make the web server start automatically when the router is rebooted:

/etc/init.d/uhttpd enable

Go to web administration

Once you have done all the above, type the following in your browser:

http://192.168.1.1

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

Resources

More info in OpenWRT's USB Essentials, USB Storage and partitioning, formatting, and mounting storage devices.

Contents: 

Tags: 

Comments

Great Post

These all are really an amazing tips about Installing OpenWRT on the D-Link and helped us a lot, keep posting useful ideas.

Great Effort

It is excellent post thanks for share your opinion. Nice work.