Here's an example of how to set up simple routing on a Linux box.
Setup:
A Linux box with two NICs
Two network switches
Two or more additional computers
1. Add this line to your /etc/sysctl.conf file and comment everything else out
net.ipv4.ip_forward = 1
2. Modify the following files in /etc/sysconfig/network-scripts
ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.80.138
NETMASK=255.255.255.0
GATEWAY=192.168.80.1
ifcfg-eth1
DEVICE=eth1
IPADDR=192.168.49.132
NETMASK=255.255.255.0
GATEWAY=192.168.49.2
route-eth0
GATEWAY0=192.168.49.132
NETMASK0=255.255.255.0
ADDRESS0=192.168.49.0
route-eth1
GATEWAY0=192.168.80.138
NETMASK0=255.255.255.0
ADDRESS0=192.168.80.0
3. Setup your other machines so that their gateway is 192.168.49.132 or 192.168.80.138
Use the GUI in Windows or use the following command in Linux:
route add default gw 192.168.80.138
Test from windows client:
>ipconfig
Windows IP Configuration
IP Address. . . . . . . . . . . . : 192.168.80.142
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.80.138
>tracert 192.168.49.130
Tracing route to 192.168.49.130 over a maximum of 30 hops
1 1 ms <1 style="font-weight: bold;">
Friday, October 31, 2008
Making Linux a Router or Gateway
Labels:
gateway,
howto,
linux,
net.ipv4.ip_forward,
route,
sysctl.conf