Build a DIY router with Linux

Before you tackle the question of whether or not you should build a DIY router, you should have a good idea of what one actually is. Routers are computers. Just like people build servers serve data or provide a service, they also build routers to perform a specific task.

Router manufacturers customize their own router configurations and build specific limited computers to support them. That’s all an off the shelf router is. Most of the time, those routers are cell phone processor sitting on a custom built motherboard, and they’re running either Linux or BSD with some customization.

A custom DIY router is just a computer that you built to serve as a router. You can choose your own hardware and build in a lot more power. The operating system and configuration are also up to you. You can add additional services, like networked storage and VPNs, and you can update and change them on-the-fly. A DIY router is a router that you control.

Cost

DIY Routers beat storebought ones

It’s hard to compare cost. Any time you’re building your own computer, you can choose something very minimal or venture into gross excess. The choice is yours. That said, there are some direct comparisons that you can make, especially with the ballooning costs of high-end routers.

It’s not worth comparing a DIY router to a cheap off the shelf one. The DIY router is always going to be much better and cost more. Cheap routers are cheap for a reason; they’re usually junk. They might work for light Internet use on a couple of devices, but that’s not why you’re here. If you’re reading this, you have a robust network that needs to be well supported, and that’s where you can make a real comparison.

As of now, higher end wireless routers are selling in the neighborhood of $300-$450. These are full featured routers at the top of the consumer market, and they’re loaded with additional wireless bands and “features” like the ability to configure cloud backups.

It’s also possible to get more average routers in in the $150-$250 range. They’re pretty good, but not great for handling a ton of traffic.

What about DIY routers? Again, the cost can really range. You can build a $2000 router, with a massive built in network drive, if you really want to, but that’s not what post people are thinking of doing.

You can put together a reasonable DIY router for right around the same price range as the leading off the shelf ones. An embedded motherboard/CPU combo is easily attainable in the $70-$80 range. RAM for that board can be found for around $30 for 4GB. Then, you can add in an SSD for about $80. An Ethernet NIC costs $40, and a good Linux-compatible PCI WiFi adapter can be bought for between $60-$100. Then, throw in a power supply and a case for about $30 each. The total comes out between $340 and $390. That’s right in the range. Given, those are rough numbers, but you can probably go even lower.

Benefits of Going DIY

Build the router you want

So, the cost is pretty much a wash. Why would you go through the trouble of setting up your own router, then? That comes down to two big points, control and power.

DIY Routers give you complete control over what your router is and does.  Building a DIY router eliminates the need to shop around for router features. You can make the router have the features that you want and design the hardware configuration to support them.

You also have control over updates. Router manufacturers don’t like supporting old models for long after the new ones have been released. Open source router firmwares like DD-WRT fall ridiculously far behind and dependent of volunteers to maintain. With your own DIY router, you control the updates. If you want only security fixes and maximum stability, base your router off of something like Debian or FreeBSD stable. Do you want the latest all the time? Run Arch, Gentoo, or FreeBSD current. It’s entirely up to you.

DIY routers are way more powerful than anything that you’re going to buy off the shelf. Even the top routers can’t compete with their DIY counterparts. The commercially available routers use ARM based processors, like phones. A DIY router contains an x86 CPU like a desktop or laptop. The difference in processor power is massive.

That doesn’t take into account other awesome power boosts, like more and faster RAM and solid state drives. Combine everything, and you’ve got a much beefier device that can handle a lot more load.

CPU power impacts network performance. A weak router can’t handle massive bandwidth and can tank your Internet speeds. When you throw in file transfers, streaming, gaming, and the countless other simultaneous tasks that an active network performs on a regular basis, you’re asking for trouble when using an inadequate router. A DIY router will never have this problem. It will only ever see limits from your ISP and maybe your wireless card.

Drawbacks

There are two main drawbacks to building your own router. First, the footprint. DIY routers are bigger and require more power to run. It’s not like you’re running a big production server, but it is a small desktop.

The other and main drawback is the extra work to set it up. There is nothing plug-and-play about building a DIY router. You are responsible for everything. That includes installing Linux or BSD and configuring it to function as a router.

You are also responsible for all maintenance, including updating the system, and keeping track of security issues that may affect your router. If something goes wrong, you’re on your own. There is no warranty or manufacturer to call.

How To Build Your Own Router

There are two different ways that you can handle the software on your router. You can choose a router-specific distribution of Linux or BSD. This is a much easier option. You can also choose to build everything from scratch with a bare-bones server installation of the Linux or BSD distribution of your choice.

The Easy Way

pfSense router operating system

If you want less maintenance and are okay with giving up some control, you can use one of the great distributions available for routers. These operating systems are loaded with features are come configured and ready to use. You just have to install them.

pfSense and OpenWRT are both excellent router operating systems. pfSense is based on BSD, and has a reputation for security. It is very well documented and has available professional support.

OpenWRT is Linux-based, and is available for a wide range of hardware. It is also well documented and provides and experience that should be familiar to anyone who has worked with custom router firmware before.

The Awesome Way

If you want something really custom, you can set up a router from scratch using Linux or FreeBSD. This guide is going to cover Linux, since it’s more popular, but FreeBSD is also a great option.

You can use just about any Linux distribution to make your DIY router. It’s probably best to pick one that you’re familiar with. Some, like Arch Linux or Gentoo, can give you a very minimal footprint, but unless you’re familiar with them, you’re going to run into problems. Whichever distribution you chose, don’t use the full desktop installation. Opt for a more minimal server install. You don’t need a desktop interface, and it’ll just slow down your router.Linux is a great choice for routers

This guide isn’t going to go into specifics for setting up your DIY router. That’s a distribution specific topic that requires a lot more detail. It will cover the basic steps to help you determine if building your own Linux router is right for you.

Start off by installing your Linux distribution on your hardware. Installing Linux is outside the scope of this guide, but the installers on user friendly distributions like Ubuntu are nearly fool-proof, so you shouldn’t have a problem.

Once you have Linux running, you can begin configuring your router. The first thing for you to do is to configure your network interfaces. Start by installing and setting up DHCP, to handle the assignment of IP addresses. One Ethernet port must be assigned to the WAN(Internet) connection. Configure that one to use DHCP. Then the rest of your Ethernet ports must be configured for the LAN. These should use a static IP. If you have more than one, you need to set up a network bridge to bind them to the same IP address.

Once you have the network interfaces configured, you have to set up port forwarding. This will allow you to pass traffic between interfaces.

The iptables firewall handles everything else. Iptables allows you to direct the flow of network traffic within the Linux system. It is through iptables that you can pass traffic across the LAN as well as between the LAN and the Internet. Iptables also allows you to configure important parts of your router like NAT, DNS, DHCP, and the firewall itself. You absolutely need a firewall to prevent unfettered access from the Internet to your network.

If you are using a wireless network, you also have to download and configure hostapd. Hostapd allows you to create a wireless access point like you would with a regular wireless router. Hostapd enables you to use features like wireless encryption to secure your WiFi network.

Is DIY Right For Me?

Only you know if you want to embark on this journey. Creating your own DIY router does have its distinct benefits. It also means that you have to be responsible for building and maintaining a critical piece of network equipment that is the gatekeeper to your home network and all of the data on it. The choice is ultimately yours.