Thursday, March 14, 2013

Replacing my ancient linux router with a Raspberry Pi

So I like to make use of hardware as long as possible and for literally a decade, I have been using an old Pentium 166 MHz (yes, you read correctly!) as my primary home router (running ubuntu linux).  This should be some indication how amazing linux is that it can make use of such old hardware.

Here is what the back looks like:

As you can see, this behemoth has four Network Interface Cards (NICs)  in it.  One of them (the bottom one) is so old that I don't even use it anymore but I kept it in the machine just for sentimental reasons.  It most certainly is an ISA NIC.

Lately I've had performance problems on the upload side of things (when traffic shaping is enabled) so I've decided that the P166 finally needs to go.  I was gonna replace it with one of the other old PC's I have lying around (such as an Athlon 800) but Warren pointed out that using a PC to act as a router wastes a lot of power so he suggested using a Raspberry Pi instead!  I thought this was a great idea.

My network at home has two subnets, one for my LAN (more permissive) and one for my wifi (more restrictive).  And I use DSL.  This means that I actually need my router to have three NICs.  The Raspberry Pi only has one NIC built in which means I needed to order a couple of USB NICs.

After doing some research, I read from the community that the ASIX chipset works well on the Pi, so I found some USB NICs with this chipset (plugable brand).  I also ordered a USB hub to help power the NICs and the Pi itself.  More on this later.  Finally, I ordered a case for the Pi since it is going to be my new router and I don't want my kids destroying it.  Here is how my setup now looks:

Now regarding power, this is where I am a little nervous.  Powering the Pi via the USB hub and then attempting to power both USB NICs at the same time proved too much for the Pi (I got flaky behavior).  So I currently am powering both of the USB NICs from the USB hub itself and then plugging the hub into the Pi.  This _seems_ to be working fine for now but I still am a little nervous about the system having enough power.


I've seen some problems including a kernel crash.  I am not ready to declare this setup stable.


Performance is really important to me so I wasn't sure whether the Pi was really up to the task considering its USB support isn't exactly stellar.  But so far, it seems to be doing a great job.

As far as internet is concerned, my max speeds over my "12 megabit" DSL currently are about 1300kB/s down and 91kB/s up (yes the upload speed sucks in comparison).  I am getting full speed from my LAN (through the Pi) so that is fine.  And over wireless, I am getting near full speed (just got 1200kB/s on my android phone next to the wifi access point).  Sending from LAN to wifi (through the Pi) gets about 3 megabytes/second.  On a subsequent test, I am getting 1.69 MiB/s which can be affected by a number of factors (my neighbors for example).  Sending from wifi to LAN (through the Pi) is about 2.75 MiB/s.

I also have quite a few iptables rules setup on the Pi (for firewall stuff) as well as traffic shaping.  It is handling both like a champ.

Here is the final parts list of what I am using (successfully) :

USB power cable
USB hub
USB NIC (x2)
Raspberry Pi case
and of course...
Raspberry Pi


  1. I'm curious as to why you insist on using a PC as your router, rather than a device that has hardware designed for the task? If price is a concern, you can grab a relatively cheap and outdated Cisco router that will perform better than this setup and most likely be much more stable...

  2. Well, my goals are twofold:
    a) keep wifi network separate from LAN network in case my neighbors crack my WPA2 passphrase
    b) have a lot of control over QoS rules so that I can do things like be constantly uploading to a backup site (crashplan in my case) while still having responsive internet. Another use case is having a LAN party where a bunch of people are playing a first person shooter on the internet and one guy is downloading a bunch of patches; I don't want his downloading to aversely affect the rest of the players.

    Perhaps a cisco router would shine at these tasks. However, I have no knowledge of how to use them or configure them and learning how to do this would be an additional cost. I already know how to do it in linux.

    re: stability, I think after firmware/kernel upgrade, the Pi is now pretty stable as a router. I am pleased with it.

  3. Matt!
    "in case my neighbors crack my WPA2 passphrase" Are you living next to the Chinese government? Can you crack a WPA2 passphrase? I can't. So long as your passphrase is over 32 characters, and your neighbors aren't out to get you, I think you can rest easy.

    Personally, I use Linksys/Cysco wireless and wired routers running "DD-WRT" firmware, which is Linux, and you can customize it if you want.

    But then again, It's not as cool as a Rasberry Pi! :)
    Love your blog Matt, keep up the good work.

  4. Which Linux version did you install in the raspberry?

  5. I wish there were a HAT (hardware attached on the top) for the Pi which gave it an additional four or eight RJ45s... and (why not?) an excellent wifi radio. That would be a kickstarter project I would buy into.