Tuesday, June 29, 2010

Asterisk, the VoIP Server on DD-WRT

I'm a big fan of Asterisk on router -- imho, it's the perfect platform for anyone want to try Asterisk at home -- 24x7, fanless and even the cheapest router can handle at least 2-3 concurrent conversation. Before this WZR-HP-G300NH, I had Asterisk running on a WRT54G-TM for over a year with lots of fun.

Installing Asterisk on the router is easier now as current OpenWrt trunk build(the one we use) includes prebuilt Asterisk binaries. As always, since OpenWrt is designed to work with / not /opt, some adjustment is required to get Asterisk working properly.

  1. Install Asterisk 1.6

Read More...

Lighttpd and php on DD-WRT

Busybox httpd is good for simple static pages, now here is a tutorial for installing lighttpd and php with fastcgi support in the router. Here I choose lighttpd over Apache for its light cpu usage and small memory footprint.

Since all our software are based in /opt folder, some modification must be done to get everything working:

  1. Install php5 and lighttpd

Read More...

Monday, June 28, 2010

Simple busybox http server on DD-WRT

By default DD-WRT runs its own http server(/usr/sbin/httpd), providing web management interface to configure the router. The server is highly integrated and hard to reuse for our own contents. If you just want to host some web pages without CGI support, the httpd server in busybox is a good alternative.

  1. (Optional)Move DD-WRT's web admin to another port

Read More...

Sunday, June 27, 2010

Upgrade DD-WRT and Keep Installed Applications

The DD-WRT support for these new 11N Gigabit routers are still in early stage with new builds rolling out every one to two weeks. The old good "if its not broken then don't fix it" rule might not apply here and I suggest to stay with latest release if you have the time(and guts).

Upgrading a DD-WRT firmware with loaded software is pretty easy, considering the extra work we've done. Take the trouble not to mess with important system folders like /lib /usr and /bin and now its the reward time.

  1. Stop installed software

Read More...

Workaround for Stuck Beacon Problem

Stuck beacon is a notorious problem on madwifi (the wireless driver DD-WRT used for Atheros routers).  If you never experienced any wireless interruptions with DD-WRT then just ignore this article. However, if you're annoyed by this stuck beacon problem with constantly dropping wireless connection, then I hope this can be of help.

I personally prefer the open source ath9k driver which doesn't suffer from this, but some important feature like WDS is missing from ath9k. So to each its own, DD-WRT has the perfect reason to stick with madwifi and I don't expect the switch to ath9k anytime soon. And, seems that the problem only happens under certain circumstance. In my case, the connection drops with an Atheros wireless N card -- same card works great with stock firmware -- but works fine with another Intel WiFI 1000 11N card. So if a stable wireless connection is very important, the best solution might be flashing back to stock firmware or just try another card.

Below is a quick hack, not a completely fix but would make life a little easier. The idea is to watch the output of dmesg and when the "stuck beacon" error messages flood, reset the wireless interface to bring it back to life.

Read More...

Wireless Scheduler with Cron Job

Cron is a time-based job scheduler in Linux systems which enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. In this example, we'll use cron to control the wireless signal, set it to turn on only at given time.

DD-WRT is shipped with cron support but again we'll use our own cron daemon as it's easier for future update and will save some flash wearing.

  1. Disable DD-WRT's Cron

Read More...

BitTorrent Client: Transmission on DD-WRT

If you've followed the previous guides to set the opkg system, then installing transmission on the USB enabled DD-WRT system is a no-brainer. Only one little thing needs to be taken care of...

  1. Install transmission

Read More...

Saturday, June 26, 2010

Advanced Printer Sharing with hotplug

Hotplug is a set of scripts running upon certain predefined conditions. On today's Linux system, hotplug can do many things from auto mounting USB drive, pairing bluetooth devices to network configuration.

Seldom mentioned, but DD-WRT does offer (very preliminary) hotplug support. With almost no info on the web, the job is done by digging though DD-WRT's source code and various Linux documents.

  1. Replace DD-WRT's event handler with our own

Read More...

Printer Server for DD-WRT(the simple version)

With USB port on the router, a normal USB printer can be hooked and become a network printer with wired or wireless capabilities. As the router is usually on 24x7, there is no need to invest a (usually overpriced) dedicated printer server or plug the printer around.

The printer server program we use here is p910nd. It's a very small(only 8KB) daemon which simply redirects all printing command from PC to the printer.

Setting p910nd on the router can be a snap or very comprehensive depends on the printer. The best scenario would be sharing a Postscript/PCL compatible one and will be covered here.

Before start, you'll need a USB hub if your router has only one USB port as we now need to connect a USB drive and a USB printer. Unpowered hub is good for USB flash drive or hard drive with external power supply while I would suggest a powered hub for hard drive solely relied on USB power to prevent overload or damage to the HDD.

  1. Set DD-WRT support for USB printer

Read More...

vsftpd: FTP Server for DD-WRT

I generally prefer Samba over FTP as it gives a better experience by allowing user to access the files as if they're still on local disk. And, unlike FTP, media files can be played directly from Samba share. But one might still need FTP server as it offers better performance over Samba.

Read More...

Friday, June 25, 2010

Samba the File Share Server in DD-WRT

It's not an easy job to configure Samba share in standard DD-WRT because by default, the /etc folder is read-only. So before start, please following the previous tutorial to set a writable /etc. Also, might to your surprise, DD-WRT does have a Samba3 built in the firmware and it works just fine. In this article, you'll be guided through the whole process to set up a password protected samba share with customized username/password.

  1. Check if there is a Samba server built in

Read More...

Thursday, June 24, 2010

Set DD-WRT to Use Local Time

This never looks to be a problem since DD-WRT provides such extensive options. Unfortunately, unlike Tomato and OpenWrt, which do a good job, DD-WRT's approach is way off and completely wrong.

A Linux box can keep its time in either local time or UTC -- both are fine as long as the corresponding time zone info is presented. However, in DD-WRT, the time zone info is completely missing and instead of standard implementing used in almost all Linux distros, DD-WRT  coins a weird scheme to setup(and keep) the time.

For example, 8AM PST(GMT-8) should be 4PM GMT, but a DD-WRT router would "think" the current time is 8AM GMT. Now if you change the time zone to EST(GMT-5), what will the router think? 11AM GMT!! Yes, that's after you've set all the "time zone" info in DD-WRT web management page. This is usually not a problem if you just want to use it as a router but for a Linux server, you definitely don't want to deal with any file created in future.

Now here is the fix:

  1. Disable DD-WRT's own NTP client

Read More...

Software Installation on DD-WRT -- Part 2

In previous part, we have everything settled(almost). Now its the time for some more fine tune.

By employing the techniques in Part 1, we have the following setup upon each reboot:

  • A USB drive mounted and accessible at /mnt
  • A writable /etc folder(actually /mnt/etc) and has exact same content as original /etc folder
  • A writable /opt folder(actually /mnt/opt) -- where all future software will be installed and run from(/opt/bin, /opt/sbin, /opt/usr/bin, just name a few) and keep the original DD-WRT folders like /bin /sbin untouched.
  • A writable and persistent /tmp/root(actually /mnt/root). This will be the home folder for user root
  • An empty file /mnt/optware.enable. This is used to control the whole optware installation. By renaming or deleting this file, all customized software/modification WILL BE DISABLED and thus put the router back to standard DD-WRT. This is useful for debugging and firmware upgrading.

Still, there is something left to do, notably that, with current setup, the LD_LIBRARY_PATH and PATH variables have to be set each time before running any command. We might also want to run some installed software as service.

  1. Set the initial variables

Read More...

Software Installation on DD-WRT -- Part 1

One thing interesting about the router is its exotic hardware specification -- 400MHz processor, 32MB flash ROM, 64MB RAM and most important of all, a USB port. All these make the router a very versatile little Linux box with tons of capabilities. However, one thing might confuse non-experienced users is that, the CPU in the router is MIPS(MIPS in big-endian), while the popular Broadcom routers(such as Linksys WRT54G) are MIPSEL(MIPS in little-endian). I don’t want to go into technical detail here, but just remember, even both are MIPS, they’re different and prebuilt binary for Broadcom routers WILL NOT work on this WZR-HP-G300NH and other Atheros based devices.

Thanks to the OpenWrt guys, with some effort, we can now put the OpenWrt binary on this router and it will run as good as the popular “optware”.

In this tutorial, I'll guide you through the process and all software will be installed on USB disk though the Buffalo router has a gorgeous 32MB flash ROM. The reason is simple – the flash ROM jffs partition will NOT survive during a firmware upgrade and you definitely don’t want to reinstall everything again each time. Also, USB disk is much faster than internal flash.

This guide will also work with other USB enabled Atheros routers such as TP-LINK TL-WR1043ND, Linksys WRT160NL, D-LInk DIR-825 RevB and Netgear WNDR3700

  1. Prepare the USB disk

Read More...

Wednesday, June 23, 2010

Firmware flash and brick recovery through TFTP

Though the whole flashing process can be done via Web interface(dd-wrt to stock and vice versa) without getting your hands dirty, still, there're cases that the Web flashing is not sufficient. One common scenario is a bricked WZR-HP-G300NH, i.e., no web access and no ping response due to bad firmware or wrong operation, or you just want to try other firmware like OpenWrt. Luckily that the WZR-HP-G300NH has a robust bootloader and the router can be recovered by using TFTP, either in Windows, Linux or OSX.

Read More...

Monday, June 21, 2010

Flash between DD-WRT and official firmware on WZR-HP-G300NH

Flashing DD-WRT on this router is extremely easy now -- thanks to the hard work of DD-WRT developers and the officially partnership with Buffalo.

Read More...

Friday, June 18, 2010

About WZR-HP-G300NH and this blog

Have been looking for a new router to replace my old trusty WRT54G-TM(the T-Mobile version of WRT54GS v3) since early this year. My case might be somewhat unusual than others, as besides standard routing jobs, this router will also serve as a 24x7 Linux box, so open source firmware compatibility is a must.

Read More...