LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 10-21-2004, 03:42 PM   #1
baz2
Member
 
Registered: Nov 2002
Posts: 73

Rep: Reputation: 15
linux as a router?


I want to use a Linux box as a router between two networks, one with an external gateway and one without. Say the one with the gateway is 192.0.1. and the one without is 192.0.2. On the 192.0.1 network 192.0.1.1 is the gateway. So I install linux on a box with two nics, and configure one as 192.0.1.2 and the other as 192.0.2.1.

What do I do on the linux box so that traffic coming in on 192.0.2.1 interface is routed to the 192.0.1.2 interface? And how do I configure workstations on the 192.0.2 network so that they can get to the 192.0.1.1 gateway (and thus to the internet)?
 
Old 10-21-2004, 03:51 PM   #2
BillJennings
Member
 
Registered: Oct 2004
Location: Big River, California, USA
Distribution: Debian
Posts: 48

Rep: Reputation: 15
Set the router's default route via 192.0.1.1 and enable ip forwarding:

Code:
ip route add default via 192.0.1.1
echo 1 >/proc/sys/net/ipv4/ip_forward
Hope this helps.
Bill Jennings
 
Old 10-21-2004, 05:15 PM   #3
baz2
Member
 
Registered: Nov 2002
Posts: 73

Original Poster
Rep: Reputation: 15
Thanks! I thought it would be something like that.

But on the 192.0.2 network, do I configure the hosts for a gateway of 192.0.2.1, or 192.0.1.1?
 
Old 10-22-2004, 02:33 AM   #4
BillJennings
Member
 
Registered: Oct 2004
Location: Big River, California, USA
Distribution: Debian
Posts: 48

Rep: Reputation: 15
The gateway must always be on the local subnet (it must be directly accessable via a connected route). So...

If the computer address is A.B.C.D, then by tradition it's gateway is A.B.C.1.

Got it?

Sincerely
Bill Jennings
 
Old 10-22-2004, 05:03 PM   #5
baz2
Member
 
Registered: Nov 2002
Posts: 73

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by BillJennings
The gateway must always be on the local subnet (it must be directly accessable via a connected route). So...

If the computer address is A.B.C.D, then by tradition it's gateway is A.B.C.1.

Got it?

Sincerely
Bill Jennings
I do. But I'm still having some problems, after all. Let's back up and reconsider how I've got things configured. (I've changed the ip scheme a bit to make the distinctions in the two networks more obvious.) In the "router" I have two nics. The ip addr for eth0 is 172.16.0.3/24. On this network, the lan side of the router (to the internet) is 172.16.0.1. The ip addr for eth1 is 192.168.0.1/24. I want this to be the "gateway" for a second 192.168.0/24 network.

From the "router" I can ping hosts on either network (172.16.0/24 and 192.168.0/24). From hosts on the 192.168.0/24 network I can ping the gateway (per above, 192.168.0.1) and I can ping 172.16.0.3. Can I infer from the latter that the "ip route add" is doing its job?

Where the problem comes in is that while my 192.168.0/24 hosts can ping 172.16.0.3 (the ip addr of eth0 in the "router"), they cannot ping any other 172.16.0/24 host, including 172.16.0.1 . And without that, they cannot get to the internet (which is the ultimate objective).
 
Old 10-23-2004, 06:24 PM   #6
baz2
Member
 
Registered: Nov 2002
Posts: 73

Original Poster
Rep: Reputation: 15
Anybody else have any ideas here? Seems a common enough question, as others here are asking something similar .

What it boils down to, in my case, is two networks or subnets, say A and B. A is connected to the internet through a router. B is not. I have a linux machine with two nics, one on the A subnet, and one on the B subnet. What do I have to do so that hosts on the B subnet can get to the internet?

I've taken Bill's suggestion as far as I can. Hosts on B can get to the nic on A, but cannot get to any other host on A, nor to the router to the internet on A.

Is there a route table, either on B, or A, or both, that I need to pull this off?
 
Old 10-26-2004, 03:46 PM   #7
baz2
Member
 
Registered: Nov 2002
Posts: 73

Original Poster
Rep: Reputation: 15
I gave up.

Scrounged up an old P166 and configured it as a freesco router instead. Why couldn't setting it up in linux directly been as easy?
 
  


Reply



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
Small Linux Router/firewall behind D-Link Hardware router dleidlein Linux - Networking 6 04-30-2007 05:12 AM
Linux Router & Netgear Wireless Router DMaCATO Linux - Wireless Networking 1 04-30-2004 09:16 AM
/etc/resolv.conf configuration when behind a router(not a linux router) rmanocha Linux - Networking 2 04-28-2004 01:52 AM
Linux Router robe8 Linux - Security 2 03-28-2004 09:49 PM
ADSL Router + Linux Router + LAN = HELP!!! linuxlois Linux - General 2 09-16-2003 08:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:52 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration