Discussion Locked

How-to set up a Linux box as router

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
A couple of years ago you had an artical on you you can configuer a linux computer to serve as a router. I printed it, and have lost it. I'm seting up a wireless internet connection for my home and have more computers than routers.

5 replies

by curtis

There's also Freesco.org and Clarkconnect.org. Both are easy to set up and provide relieable firewalling/routing. Freesco fits on a floppy, but clarkconnect requires a hard drive to install.

by penguinvitamins2

A simple router requires 2 network cards. (OK having one with multiple virtual networks configured is also a possibility).

In this example I use 2 Ethernet adaptors. (on RedHat) Linux's naming conventions for Ethernet adaptors is eth0, eth1, eth2 etc....

to Determine which is which of the 2. Connect one adaptor to a live network point and run a tool called mii-tool
This will indicate the link status. Note the card name.

Interface configurations are stored in /etc/sysconfig/network-scripts/ifcfg-[cardname]
The machine's first Ethernet network interface is eth0 and is stored in /etc/sysconfig/network-scripts/ifcfg-eth0

Edit these files or use redhat-config-network to configure them. Configure the cards to reflect the 2 networks. Remember a machine should only have one default gateway (indicated by 0.0.0.0) and is only necessary if your router will require routing network packets that is multiple hops away. The simplest method is to configure the default gateway on the card that have lots of unknown networks and configure the other card with static networks/hosts. Or configure both to have static networks. Or use a program called zebra to make your box RIP/OSPF aware.

Last action: Allowing packets to be routed you require to set the ip_forward "switch"

To activate this in realtime (without a reboot) enter the following.

echo 1 > /proc/sys/net/ipv4/ip_forward

this replaces the "0" in the file to a 1, enabling packet routing

To make it permanent (resident after reboot):

Edit the file /etc/sysctl.conf
change the "0" on line net.ipv4.ip_forward=0
to a "1"
Save and exit

Routes can be added using the command "route"

route add -host [someip] netmask [somenetmask] gateway [someremotegateway] [interface to route through]

route add -net [someipnetrange] netmask [somenetmask] gw [someremotegateway] [interface to route through]

example route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254 eth0

by dgelect

would recommend coyote linux we use it a lot.

remember you need 2 nic's pref not the same type or mfg

This discussion is closed to new replies.