Most routers run a variant of Linux. There's typically a set of hardware interfaces and a simple web server running on top of a generic Linux kernel, with the routing, filtering and Wi-Fi management running as separate processes. If you want to see this in action, you'll find your router may already offer a back-door debug mode which gives you Telnet access to the file system. For example, for a Netgear DG384G the command is http://[local ip address]/setup.cgi?todo=debug, where the [local IP address] number is the LAN's IP address. Put this line into a browser with the router's IP number, and you'll get a terse message saying 'Debug Enable!'
You can now use the Windows Telnet tool to have a look inside the router's file system. Select 'Run' from the Start Menu, and type 'telnet [local ip address].' You should see a DOS window with a prompt. Type 'ls –l' to see a list of files. Unfortunately, you can't use Telnet to copy these files and the built-in BusyBox shell – the command line interpreter – doesn't include an editor. This means you can explore the directory structure using 'cd' and 'ls', and view files using 'cat.', but you can't change anything.
The time consuming answer is to download the source from the manufacturer and start working to customise it yourself. You'll find that the features will usually have been bolted together from some generic free open-source tools, such as the BusyBox shell we mentioned earlier. Proprietary code is there to keep the various parts working together and to add specific hardware drivers. Even so, customising the code from the ground up is an ambitious job and if you get it wrong you may end up bricking your router.
If you're feeling brave the hacking community can offer various pre-written customisation projects for you to experiment with, as well as forums and support which will help you get started. Openwrt (http://openwrt.org) offers the best range of hardware support, but many models are still classified as WIP – Work in Progress. Openwrt is flexible, but not friendly. While it's possible to write your own scripts to add features, the development model isn't straightforward. Setup isn't simple, either. However, if you're used to Linux you won't find it too daunting – it's no harder than setting up other Linux tools.
The most popular router by far for customisation is the LinkSys WAG54G series. Like all routers, this has developed through a range of variants and updates. Also, like all other routers, this has often meant that only the box has remained similar – the circuitry and chipsets used in various models are completely different, so check the model and version number carefully before trying to flash some custom firmware.
If you have one of the variants you have a choice between a selection of projects, including freewrt (www.freewrt.org/trac), ddwrt (www.dd-wrt.com/dd-wrtv3/index.php), openwrt and Tomato (www.polarcloud.com/tomato). Tomato adds the widest range of extensions and options, including static DHCP, which can speed up network connections, and the ability to add bridging features, so that you can use multiple routers to extend range. If you want the most powerful possible router for the least cost, it's worth buying a WAG54G model just so you can install these features on it. You'll get high end professional options for the cost of a much cheaper unit– and that can't be bad.