Linux Multiple Wan Routers

A short tutorial on building your own dual wan router.

The first thing you will obviously need is a computer running linux, Distro choice is completely up to you and if you are an experienced Linux user you should choose something that you are comfortable with. New users can go to LinuxISO and learn more about linux Distributions. The only requirement is that the kernel is version 2.4 or newer. Preferrably a 2.6 based kernel should be used.

You will need more than one network card for this project, 1 card for your internal network and 1 card for each external connection (internet connection) IE the most basic multiple route will be 3 network cards. This site will focus on load balancing 2 internet connections however its very simple to apply these principles to additional connections.

For simplicity we will deal only with static IP’s if you have internet connections with dynamic IPs there are several ways to create the illusion of static IP’s for the purpose of your Multiple route gateway. I suggest setting up the connections on small Smoothwall boxes in different IP ranges and subnets to achieve this.

Although standard Linux kernels are partially capable of simple multiple routes we will be using patched kernels to improve functionality and preform more advanced routing functions. This will be explained in detail at a later point in the tutorial.

There are example scripts available on this page which are simple to implement and fully functional. However I do still recommend that you read through all the documentation provided to assist yourself in better understanding what you are achieving and how.

So its really simple to get started all you need is Linux and a few network cards.

The first thing that you will need to do is get the appropriate patch from here once you have the correct patch you will need to apply the patch to your kernel, this is done by entering the following command from console, “/usr/src/linux # patch -p1 < file.diff” To test before actual change: /usr/src/linux # patch -p1 –dry-run < file.diff

Note: you need the -p1 option for all patches

Once the kernel has been patched, restart the machine and your ready to move on.

Building routes can be quite complex depending on your configuration, we will once again assume that you have static IP’s and are planning to balance 2 connections.

You can follow the guide here or if your already comfortable with interfaces and IPTables you can modify this script.
.
The next thing you might want to look at is firewalling your box, there are several ways to go about this, I suggest FWBuilder which supports IPTables/Chains.

You might want to stick a Proxy between your Router/Gateway and your Internal Network, this will save bandwidth and keep things loading faster.

Leave a Reply