Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 09-08-2010, 03:08 PM   #1
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
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:

'Hope that helps!

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

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
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.
Old 09-09-2010, 05:33 AM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
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 or 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.


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 > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:36 PM.

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