Why do you need a home router? The answer is really simple. If you can't afford buying a good router ot switch (the good ones are really expensive) and you have more than one computer, the first thing that is coming up in my mind is for security purposes. The second thing is that is always good to know what's going on in your house. To be able to make services forbidden and so on.
NOTE: The following example is made with customized Gentoo Linux mashine (two LAN cards) and another mashine (in our case, another Gentoo Mashine, but you can use whatever you want...)
To get the computers
conected together you need a Crossover cable.
You can buy one, or if you feel like you may make one following these
directions :


You need a Linux
Distribution with IPtables ( all the latest
distributions have IPtables already compiled during installation ), if
not you can always download it from the Official
Website.
Then you need a DNSMasq (small and easy to configure DNS forwarder and
DHCP server) available in the package managers on every distribution or
here.
Ok Let's get started. First you need to configure your kernel :
kickar@linnewbies
~ $ cd /usr/src/linux
kickar@linnewbies /usr/src/linux $ sudo
make menuconfig
We trust you have received
the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy
of others.
#2) Think before you type.
#3) With great power comes great responsibility.
Password:
scripts/kconfig/mconf arch/x86/Kconfig
.....................................
kickar@linnewbies ~ $
You need this options as *
Networking options
--->
[*] TCP/IP networking
[*] IP: advanced router
[*] Network packet filtering (replaces ipchains)
You can put the rest in this section as M, just in case you need it later on. When you are all set it is time for recompiling kernel :
kickar@linnewbies
/usr/src/linux $ sudo make && make
install && make modules_install
Password:
CHK include/linux/version.h
CHK include/linux/utsrelease.h
CALL scripts/checksyscalls.sh
........................
kickar@linnewbies
/usr/src/linux $ sudo reboot
..............
Ok after we have kernel
all set and ready it is time to install all nessecary tools :
First we have to check if all of the LAN cards are up and running, you
can do that by executing the command ifconfig
:
kickar@linnewbies
~ $ sudo ifconfig
Password:
eth0 Link encap:Ethernet HWaddr 00:1e:33:83:88:ba
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:20050498626 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:124 Base address:0xe000
lo Link encap:Local
Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1752 errors:0 dropped:0 overruns:0 frame:0
TX packets:1752 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:50808 (49.6 KiB) TX bytes:50808 (49.6 KiB)
eth1 Link encap:Ethernet
HWaddr 00:60:F5:07:07:B9
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:10 Base address:0x9400
kickar@linnewbies ~ $
Your output should be similar to this one, if you do not see all of your cards you can try with lspci | grep Ethernet. Most of the distributions have ti included, but if you dont have it I am sure you can compile it from souce. For most of the Linux Distributions you need pciutils.
Now fire up your favourite text editor and edit /etc/conf.d/net. You can use nano , vim and so on ..... You need to add :
config_eth0=( "192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0" )
After adding it, save and exit. Now you need to set up an DHCP Server. DNSMasq is very nice and small DNS forwarder and DHCP Server.
For Gentoo Linux and its based Distributions using Portage :
kickar@linnewbies
~ $ sudo emerge -pv dnsmasq
Password:
These are the packages that would be merged, in order:
Calculating
dependencies... done!
[ebuild N ] net-dns/dnsmasq-2.45 USE="dbus ipv6 nls -isc -tftp" 269
kB
Total: 1 package (1 new),
Size of downloads: 269 kB
kickar@linnewbies ~ $
After checking for blocks or unsatisfied packages, you can straight emerge it :)
kickar@linnewbies
~ $ sudo emerge dnsmasq
Calculating dependencies... done!
.............................( I have cut the output to save some space
:P )
kickar@linnewbies ~ $
After installing DNSMasq you need to edit /etc/dnsmasq.conf. You need to add a line similar to this one :
dhcp-range=address,to
address,72h or in our example
dhcp-range=192.168.0.1,192.168.0.250,72h
If you want you can specify a interface that dnsmasq will listen to,
for example only LAN interface. You need to add the following line :
interface=eth0
Now when you are done with the configuration is time to add the script to default runlevel :
kickar@linnewbies
~ $ sudo rc-update add dnsmasq default
* dnsmasq added to runlevel default
kickar@linnewbies ~ $
For Ubuntu, Debian and its based Distributions :
To install it just simply run :
kickar@ubuntutestbox ~ $ sudo apt-get install dnsmasq
Password:
.............................
kickar@ubuntutestbox ~ $
After installation you have to edit it the same way it needs to be edited for Gentoo Linux, add the same lines in /etc/dnsmasq.conf
For Ubuntu Linux you have to re/start it with sudo invoke-rc.d dnsmasq re/start
For Archlinux :
Install it with pacman -S dnsmasq
[kickar@archytest
~] pacman -S dnsmasq
..........
[kickar@archytest ~]