Router: Basic
From ArchWiki
Contents |
Introduction
This article assumes that you have a fully working Arch Linux installation on a spare computer that contains at least two network interfaces. The intended purposes of this article is to allow any user who wishes to setup and configure an Arch Linux Router to share their internet connection using two network interfaces.
Getting Started
To build an Arch Linux router you will need the following pieces of equipment available:
- A Spare Computer capable of running Arch Linux
- Two Ethernet Cards
- Multiport Switch (for sharing your internet with more than just one computer)
- An Internet Connection
The two ethernet cards will need to be placed inside of your spare computer. You may need to ensure that these cards are supported by Arch Linux before you continue. Once the spare computer has been properly prepared, you can begin the installation of Arch Linux.
Features
(Do we need a features section to tell users what they will be getting? I think its relevant?)
Preparation
Once you have a fully working Arch Linux installation with two working ethernet cards, it is time to connect your Arch Linux router directly to your cable or dsl modem. The other ethernet interface will be connected to a switch or another computer depending how your network is setup.
On a default installation, Arch Linux does not come with what you will need to configure an Arch Linux router. You will need to install some additional packages to make Arch Linux function how we intend to. For this task, we will be using the package manager pacman.
Upgrading Your Packages
If you have not done so already, you should go ahead and update your installation to the latest packages. You can do this by running the following command from the command line.
pacman -Syu
Allow it to proceed and once it has finished, continue to the next part of this tutorial.
Installing Necessary Packages
The applications we will be using to create this Arch Linux router will be dnsmasq and shorewall. If you are on an ADSL connection, you will also need the package rp-pppoe. More information will be given about each of these applications as we start to configure them. Until then, install the applications by running the following command from the command line:
pacman -Sy shorewall iptables dnsmasq
Allow it to proceed and once it has finished, continue to the next part of this tutorial.
Configuring udev
Arch Linux uses a device manager named udev. The way udev works is by loading all the modules at once during start up. This means that udev cannot ensure that the modules are loaded in the same order. What does this mean for someone like us trying to setup an Arch Linux router?
Well if you remember, we currently have two ethernet devices inside our Arch Linux router machine. Since udev cannot ensure that one ethernet cards module will be loaded before the next, you will run into the case where your ethernet devices may switch names (i.e. eth0 may become eth1 and vise versa). Although exciting, this is not a very useful feauture on a router. So we need a way to tell udev which card goes where.
Create a file called /etc/udev/rules.d/10-network.rules
and bind the MAC address of each of your cards to a certain interface name:
SUBSYSTEM=="net", ATTRS{address}=="aa:bb:cc:dd:ee:ff", NAME="eth0" SUBSYSTEM=="net", ATTRS{address}=="ff:ee:dd:cc:bb:aa", NAME="eth1"
- To get the MAC address of each card, use this command:
udevadm info -a -p /sys/class/net/<yourdevice> | grep address
- Make sure to use the lower-case hex values in your udev rules. Udev doesn't like upper-case.
- Some people have problems naming their interfaces after the old style: eth0, eth1, etc. Try something like "lan" or "wlan" if you experience this problem.
Don't forget to update your /etc/rc.conf and other configfiles that is using the old ethX notation.