LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 09-08-2010, 03:08 PM   #1
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Rep: Reputation: 30
Setting up a simple, LAN-to-LAN router


Hey all,

As the subject says, I'm trying to set up a simple router on a system running CentOS 5.5. The systems has 2 NICs installed, both of which are on private segments, those being 192.168.108.x (eth0) and 192.168.109.x (eth2). The system can communicate with other systems on their respective segments.

So, I need this system to route traffic between the 108 and 109 segments. No firewalls needed, no NAT, nothing fancy. I can set up the router system as the default gateway for all other systems, or add a static route. Should be simple.

Trouble is, there is so much conflicting information on how to actually do this. Some say all that's needed is to enable IP forwarding (by way of the /etc/sysctl.conf file). Others say that iptables is needed and that NAT and masquerading are required. I have already enabled IP forwarding, but simply doing that isn't enough of course, and I'm unsure where to go next.

What's the easiest way to get this working?
 
Old 09-09-2010, 02:24 AM   #2
14moose
Member
 
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
Hi -

You're correct: you don't need to set up NAT or use iptables (although that's certainly a common scenario).

All you have to do is:

1. Configure one NIC for one network, and the other NIC for the other network.

2. Enable IP forwarding.

That's it!

If it doesn't work, please post back details about the specific problems you're encountering.

And if you haven't already done so, a useful Google search is "linux dual-homed ip forwarding"

Here's a good link:
http://www.cyberciti.biz/tips/linux-...etworking.html

'Hope that helps!

PS:
Just to clarify:
Quote:
I need this system to route traffic between the 108 and 109 segments
<= No problemo! Easy. See above.

Quote:
I can set up the router system as the default gateway for all other systems
<= You definitely need iptables if you want to exchange packets between your LAN(s) and the Internet
A good Google search for this latter scenario is "linux internet connection sharing"

Last edited by 14moose; 09-09-2010 at 02:32 AM.
 
Old 09-09-2010, 05:18 AM   #3
vickey_n
LQ Newbie
 
Registered: Nov 2009
Posts: 21
Blog Entries: 1

Rep: Reputation: 3
How to use linux as router

of course there is no need to configure NAT for using linux as router.
Use this link it will describe all the steps you need to configure Linux as router.
http://www.computernetworkingnotes.c..._as_router.htm
 
Old 09-09-2010, 05:33 AM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Double check that the computer used as the gateway has the nf_conntrack module loaded. I once used my laptop to give my desktop wireless access. It didn't work until I modprobed the tc_conntrack module (now called nf_conntrack).

Check the routing table:
sudo /sbin/router -n

Does a route exist for both LAN networks?

If the hosts access the network though another router, then that router will be the default gateway, and you need to add an explicit route to the other network, i.e. either 192.168.108.0 or 192.168.109.0 on the respective LAN segments. An exception is if your routing host has a third interface connecting to the internet router.

While you don't need to add ip_tables rules, you might consider regulating the traffic allowed between the two networks. Especially if one of them is a DMZ network segment.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LAN to LAN Router corerouter0 Linux - Networking 4 06-02-2007 06:06 AM
Setting up simple file/print server to notify me of log activity across the LAN adamsjw2 Linux - Networking 1 04-10-2006 04:59 PM
Simple LAN Server PDD Linux - Networking 19 11-02-2004 01:25 PM
Routing LAN -> WAN -> LAN with unhelpful router synx13 Linux - Networking 2 06-14-2004 03:35 PM
ADSL Router + Linux Router + LAN = HELP!!! linuxlois Linux - General 2 09-16-2003 09:24 AM


All times are GMT -5. The time now is 12:21 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration