Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to install a small program on a cheap home router that runs a Linux kernel and run it? I mean can I use a router that runs a Linux OS as a small computer to run arbitrary code on it?

I'm not trying to do any harm, i'm just curious if it can be done.

share|improve this question

migrated from Nov 1 '11 at 18:06

This question came from our site for professional and enthusiast programmers.

Yes. Look at DD-WRT. However, you won't get any normal IO devices (screen or keyboard) – SLaks Nov 1 '11 at 15:36
don't really need that. just the ability to run some scripts or a binary. i guess a binary should be compiled with the routers architecture in mind. i'll check it out. thanks – Vlad Nov 1 '11 at 15:45
up vote 4 down vote accepted

Yes, see

DD-WRT is a Linux based alternative OpenSource firmware suitable for a great variety of WLAN routers and embedded systems. The main emphasis lies on providing the easiest possible handling while at the same time supporting a great number of functionalities within the framework of the respective hardware platform used.

share|improve this answer
thanks. i'll check to see if it's compatible with my router – Vlad Nov 1 '11 at 15:43
@slhck thanks for adding the snip – hafichuk Nov 3 '11 at 4:44

Yes, but it's not easy. You have to know about device drivers on Linux, and have to get enough knowledge to write kernel (which derivative Linux on a router) code.

Linux systems make changes to their kernel which are modified by producers of machines (doesn't mather whether they are for modems, camera encoders, computers, and so on). Yes it should have Bash, but that's up to you. It's not necessary but it includes everything you want, maybe all you have to do is a task to shutdown or reboot it...

share|improve this answer
not looking into customizing the kernel, if it runs linux then it should have bash. i only need to do some scripting. like powering my main computer through wol – Vlad Nov 1 '11 at 15:42
linux systems changes up to their kernel which is modified by producer of machines(modems,camera encoders,computers etc). Yes it should have bash but up to your necessary its not include everything you want, maybe all have done task as shotdown or reboot etc. – mekici Nov 1 '11 at 15:49
@Vlad - embedded versions of Linux may not have equivalent shells like a desktop. Busybox is typically used to implement the shell and utilities, and since it is highly customizeable, some capabilities may get omitted. – sawdust Nov 1 '11 at 22:31

Possible but impractical - those devices have around 32 MB of RAM (sometimes less!), and next to no processing power. It is far easier to get one of those "nettop" cheap&small x86 computers and make it into a wireless router (e.g. using Voyage Linux).

share|improve this answer
i know it's far fetched, but i already have the router and i don't have the money to buy a new pc :) – Vlad Nov 1 '11 at 15:46
and i think the router has a lower power consumption than a pc – Vlad Nov 1 '11 at 15:47
@Vlad: Indeed it has - mostly achieved by being slower. But yes, it is possible - e.g. with DD-WRT, as mentioned by the other answers. – Piskvor Nov 1 '11 at 23:13

Of course you can. But you can do about as much on them, as you could do with a computer having the same specs. Look up your router’s CPU architecture¹ and speed, the amount of ram, and what kinds of permanent storage (internal flash memory, USB stick, USB HDD) it supports.

Basically, just treat it like any other headless PC.

The only problem is, to get a command-line, so you can install something, you need to boot your own environment. And the boot loaders of those routers usually aren’t configurable. But they all allow flashing a new firmware². So the trick is, to either find a pre-made (unofficial/custom) firmware that allows you to ssh³ in and re-flash in case you want to undo everything… or to make/modify your own firmware image*.

As soon as you have any sort of Linux command line, everything else goes as usual. The most elegant path is to install Gentoo. As it, being a meta-distribution, is extremely adaptable. Basically it’s made for exactly these cases. And in the process you learn how to actually use a computer. That is very important. Because if you don’t (like with Windows/OSX/Ubuntu/KDE), and you get to even the tiniest problem that doesn’t have a colorful clickable, you’re stuck. Make sure you use the same kernel configuration, drivers, etc as that firmware image though.

  • You can also make the firmware image with Gentoo, if you decide to create your own. But in that case, you have to find out which hardware your router actually consists of. Which CPU, which buses, which controllers. Apart from already having a command line, the only way to do that, is to open the thing, look at the text on the chips, and find their specs online. But don’t attempt to flash that, until you are sure you get either a bootable system with SSH or with re-flashing support. Otherwise you can’t go back. Which is kinda bad, if you soft-bricked the device. ;) (Unless you want to unsolder the flash memory chip, solder it into an USB stick with a compatible matching controller, and re-flash it that way, or something like that. ;)

But usually, things lite Tomato⁴ (or its predecessor DD-WRT) save you from this step… provided you have a suitable router.

If you have a Linux kernel running, and a package management system available (every distribution does), all limitations are gone. Just install whatever you like and the hardware can handle. :)

² ³

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .