Operating System - Linux
1753401 Members
7612 Online
108792 Solutions
New Discussion юеВ

Re: Linux router lan to lan

 
SOLVED
Go to solution
Tv_3
Respected Contributor

Linux router lan to lan

Can someone give me a kickstart, I would like to make a lan to lan router.

Can someone point me to documents, the only docs I found are for setting up a router/firewall lan to internet (WAN)

I have two network segments 196.168.0.X/24 and a 172.16.X.X/16 network segment witch I need to connect.

I'm not a linux wizard, I have little to non experience using linux / unix or wathever.

Any help would be appriciated.

Sincerly
Chaos, Panic or Disaster??? Always Stay Calm, I will fix it.
9 REPLIES 9
Kasper Hedensted
Trusted Contributor

Re: Linux router lan to lan

Hi,

Check out Freesco
http://www.freesco.org/

Cheers
Kasper
Stuart Browne
Honored Contributor

Re: Linux router lan to lan

Are we talking two network interfaces, one in each segment?

Then it's simple. No firewalling *required* (but can be done if wanted).

It's called "route".

Set up a simple linux box with two NIC's, each with an IP from their respective subnets.

Turn on IP Forwarding using '/etc/sysctl.conf' (net.ipvr.ip_forward = 1), and 'sysctl -p' to re-read the config (or 'echo 1 > /proc/sys/net/ipv4/ip_forward').

Set the linux box as the default route (or add a network route for the opposing subnet) to go to the Linux box.

On the linux box it's self though, set a default route to the interface of the 172 subnet, and that should be it.

Simple. ;)
One long-haired git at your service...
Gopi Sekar
Honored Contributor

Re: Linux router lan to lan


if you are having two network cards each connecting to two different networks then it is not a problem as stuart mentioned.

Make sure that all the client boxes point to this machine (which connects to both the network) as default gateway. This machine should have ip_forward enabled.

Regards,
Gopi
Never Never Never Giveup
Patrick Terlisten
Honored Contributor

Re: Linux router lan to lan

Hi,

I wouldn├В┬┤t use the linux router as the default gateway on the clients. Better set a static route for the networks with the linux router as gateway.

The router itself is pretty simple. Active ip-forwarding and use the command "route" to add the routes for the different networks (look at Stuarts posting :) ). A firewall is not required, but sometimes usefull to block traffic between the networks.

Regards,
Patrick
Best regards,
Patrick
Tv_3
Respected Contributor

Re: Linux router lan to lan

Hi Thanks all, thanks for the fast and quick responses...

As mentioned above:

Turn on IP Forwarding using '/etc/sysctl.conf' (net.ipvr.ip_forward = 1), and 'sysctl -p' to re-read the config (or 'echo 1 > /proc/sys/net/ipv4/ip_forward').

Can someone explain this a little more in detail? I believe I have to change some parameters in the sysctl.conf file?


Thanks
Chaos, Panic or Disaster??? Always Stay Calm, I will fix it.
Patrick Terlisten
Honored Contributor
Solution

Re: Linux router lan to lan

Hi,

you can activate ip forwarding on two ways.

1. Run on the shell or in a terminal window under X11 the following command:

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

After a reboot you need to rerun this command to activate ip forwarding. You can write yourself a little init-script which do that for you. But there is a second way to activate ip forwarding.

2. You need to change the file /etc/sysctl.conf with an editor of you joice (VI, EMACS, nano, kate....). You need to add or modify this entry.

net.ipv4.ip_forward = 1

After that you can reboot the system or just run the command "sysctl -p" to apply this change.

Regards,
Patrick
Best regards,
Patrick
Gopi Sekar
Honored Contributor

Re: Linux router lan to lan

By default linux does not do a router's job. i.e forwarding IP address from one source to another. The ip_forward variable is used to achieve this.

There are two methods to achieve this, either temporaray (which will last till system reboot) or permanent.

echo 1 >/proc/sys/net/ip_forward is a temporary method which will enable routing capcity in the linux box. On next reboot this will reset it back to the kernel default (which is more likely 0, disable forwarding). To make it permanent sysctl is used.

sysctl has a configuration file(/etc/sysctl.conf) which will contain all the kernel variables and their values, on every reboot the distribution runs sysctl -p which reads the values from sysctl.conf and modifies kernel parameters accordingly.

You can have all your kernel parameters value in /etc/sysctl.conf which will get updated during server boot.

For more information check 'man sysctl'

Regards,
Gopi
Never Never Never Giveup
Tv_3
Respected Contributor

Re: Linux router lan to lan

Thanks ALL !
Chaos, Panic or Disaster??? Always Stay Calm, I will fix it.
Guru Dutta
Frequent Advisor

Re: Linux router lan to lan