LinuxQuestions.org
Help answer threads with 0 replies.
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 03-19-2005, 02:51 AM   #1
razan
LQ Newbie
 
Registered: Jan 2005
Location: Unix planet
Posts: 28

Rep: Reputation: 15
Talking routing tables or forwarding through IPTABLES


I have a linux machin that is a multihomed ROUTER, GATEWAY, Firewall and proxy server. This machine has three NIC Card used to connect three diffrent network.

Internet is connected to eth0 and other two NIC i.e. eth1 and eth2 are conncected to two different n/w. Now When i used this machin simply as a router how should i confiugre and when i use it both firewall as router how should i configure it.


What i have done is i have given the gateway for the internet as the eth0 and to conncet the eth1 n/w with the internet i have given the eth0 as the gateway and similarly with other nic i.e. the eth2.

This would not work i suppose coz the ip has to be massquered . and massquered is done through ip tables.

If i used this machine as the firewall com gateway then i have to forward throug the command iptables so that they can tranfer files between.

What i am asking is do i have to configure the route when i use the machine as the gateway firewall ?
 
Old 03-19-2005, 08:54 PM   #2
gabriele_101
Member
 
Registered: Oct 2001
Location: CAMBRIDGE, MA USA
Distribution: RH9 Kernel 2.4.20-18.9
Posts: 69

Rep: Reputation: 15
Not sure what the question is here. What does the output of your
Code:
route -n
command look like (NOTE: You may want to change the first three number triads in the IP/net addresses to XXX.XXX.XXX, YYY.YYY.YYY, etc, so that you don't post your whole network information)?

I'm not sure what you are trying to do, but I have a few machines with multiple NICs at several locations, some of the servers have one NIC directly connected to the internet, and one or more connected to either other servers or a local LAN. is that what you are trying to do?

For example, when I type "route -n" on one of my servers with a NIC connected to the Internet and one to the Intranet, I get:

Code:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
XXX.XXX.XXX.19  0.0.0.0         255.255.255.248 U     0      0        0 eth0
YYY.YYY.YYY..0  0.0.0.0         255.255.255.0   U     0      0        0 eth1
ZZZ.ZZZ.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
0.0.0.0         XXX.XXX.XXX.12  0.0.0.0         UG    0      0        0 eth0
So all traffic directed to the YYY.YYY.YYY and ZZZ.ZZZ networks, goes out to eth1 that is connected to an Intranet and behind one of the firewalls, while everything else if pumped out to the Internet through eht0,

Good luck!

-Gabriele @ http://www.fariel.com
 
Old 03-23-2005, 02:55 AM   #3
razan
LQ Newbie
 
Registered: Jan 2005
Location: Unix planet
Posts: 28

Original Poster
Rep: Reputation: 15
Talking here's the detail as per ur request

Destination Gateway Genmask Flasgs MSS Windows irtt Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
172.16.0.0 * 255.255.0.0 U 0 0 0 eth2
169.254.0.0 * 255.255.255.0 U 0 0 0 eth1
10.0.0.0 * 255.0.0.0 U 0 0 0 eth1
192.168.0.0 192.168.0.150 255.255.255.0 UG 0 0 0 eth0


See the lets say that my network eth0 i.e connecte to DMZ zone to internet
172.16.0.0 is eth1 and is a one network
and 10.0.0.0 is eth2 connected to other network

in this case what i want is to to connect 172.16.0.0 network to 10.0.0.0 and vice versa and both of this network to be connecte to the internet or 192.168.0.0. network

now should i changes the setting in the routing table or I can mangage this thing from the firewall
if i have to use the firewall how should i configure the firewall so that all the request from one n/w will be forwarded and filterd accourdingly.

thanking
 
Old 03-23-2005, 06:55 AM   #4
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

this one is queer :
169.254.0.0 * 255.255.255.0 U 0 0 0 eth1
10.0.0.0 * 255.0.0.0 U 0 0 0 eth1

it should mean that eth1 is configured with 2 IPs, one in the 169.254, the other en the 10.0.0.0
the 169.254.0.0 * 255.255.255.0 U 0 0 0 eth1 should certainly be deleted.

I suppose that the following line is supposed to be your default route !?
192.168.0.0 192.168.0.150 255.255.255.0 UG 0 0 0 eth0

It should be :
0.0.0.0 192.168.0.150 0.0.0.0 UG 0 0 0 eth0
if 192.168.0.150 really is your default gateway (router/modem connecting you to internet).

Ok, that was for routing.... let's talk about packet forwarding.

So that packets are forwarded from a NIC to another you need to
echo 1 > /proc/sys/net/ipv4/ip_forward
This must be done after every reboot (a script in /etc/init.d)

Default behaviour of iptables is to accept everything. So, if I were you, I'd just let iptables appart for the moment. Just correct your routing problems, check that the different LANs are well interconnected.

When this will be done, you can use iptables to add security, and network address translation. But this doesn't seem to be _needed_ in your case, since if 192.168.0.0 really is the network config you use, then you must have a router that is allready performing NAT to connect you to internet (192.168.0.0 cannot be routed on Internet, so, no matter how, you're allready nated).
 
Old 03-23-2005, 07:15 AM   #5
razan
LQ Newbie
 
Registered: Jan 2005
Location: Unix planet
Posts: 28

Original Poster
Rep: Reputation: 15
Talking hmm ya i know

mr fr_laz thanx for the reply.
ya u r right that my eth1 is havin two IP. my FC2 is unaable to deal with the davcom ethernet and it sucks. its says that
eth1: Tx timeout - reseting. I know theres some prob in my ethernet.


okey next i got a new ehternet, i just replaced the davcom ethernet. and i have already done the forwarding part in sysctrl.conf.

so dude if theres any way that i can communicate with the between three n/w in iptables.
 
Old 03-23-2005, 07:25 AM   #6
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Re,

If you've fixed the routing table problems, and enabled ip forwarding, it should work !
Perhaps you're firewalled ? Try a "iptables -vL", "iptables -t nat -vL" and post the output....

one more question : did you give your real ip config, or did you changed them ?
If you're really using 192.168.0.0, then you must have a router somewhere, no ?
 
Old 03-24-2005, 10:14 PM   #7
razan
LQ Newbie
 
Registered: Jan 2005
Location: Unix planet
Posts: 28

Original Poster
Rep: Reputation: 15
yap m using my real ip

192.168.0.0 is my eth0 n/w connected to the router with the public IP
172.16.0.0 is my eth1 n/w connected to LAN
10.0.0.0 is my eth2 n/w connected to next LAN

now see what i want is both the LAN eth1, eth2 should be able to browse internet that is available throught the eth0 192.168.0.0 n/w

both the LAN should communicate with each other with certain previlage



eth1 eth2
-----------
| |
| |
------------------ -----------------------------
| |
| |
-----------
| Linux machine (firewall IPTABLES)
|
| eth0
|
-----------
| |
| |
-----------
| Router with publick ip and NATED
|
|

INTERNET


Linux router cum firewall(iptables)
 
Old 03-24-2005, 10:15 PM   #8
razan
LQ Newbie
 
Registered: Jan 2005
Location: Unix planet
Posts: 28

Original Poster
Rep: Reputation: 15
i designed my n/w above but

i designed my n/w above but the character space is removed i suppose
 
  


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
Routing tables TPB Linux - Networking 3 07-27-2005 09:01 PM
IP Routing Tables collern2 Linux - Security 1 05-23-2005 10:48 AM
iptables and routing tables configuration intranet_man Linux - Networking 6 12-17-2004 04:59 AM
routing tables help hadoque Linux - Networking 0 08-28-2004 09:10 AM
An Important Q about routing tables and iptables!! Farhang Linux - Networking 2 07-26-2004 06:43 AM

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

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

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