LinuxQuestions.org
Visit Jeremy's Blog.
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-22-2005, 02:52 AM   #1
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Rep: Reputation: 15
Linux Gateway with 3 NICs


I have a working linux gateway server, with 2 NIC cards. But, now I have a need for third one, cuz I now administer two seperate netorks - 2 different class IP addresses. I have installed the third NIC but I just cant get the server to route the second network wia 3rd nic. Here is my config in diagram:

ADSL Router(10.0.0.138) --SWITCH-- Server[eth2(10.0.0.80)-eth1(10.40.0.10)-eth0(192.168.1.2)]

Quote:
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.40.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 10.0.0.138 0.0.0.0 UG 0 0 0 eth2
m
I have a masquerade working also:

Quote:
iptables --table nat --append POSTROUTING --out-interface eth2 -j MASQUERADE

Last edited by pin_bk; 03-22-2005 at 07:17 AM.
 
Old 03-22-2005, 05:08 AM   #2
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Rep: Reputation: 100Reputation: 100
Masquerade seems no to work in case of multiple NIC's. You have to do SNAT instead.
ex.:
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to your.public.ip.x
(if eth0 is the NIC connected to your modem/router)
 
Old 03-22-2005, 05:15 AM   #3
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Original Poster
Rep: Reputation: 15
The point is that the public IP is on the router which handles NAT, so will the SNAT thing work?

Last edited by pin_bk; 03-22-2005 at 05:16 AM.
 
Old 03-22-2005, 06:14 AM   #4
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Rep: Reputation: 100Reputation: 100
If masquerade works, then snat will surely works.
 
Old 03-22-2005, 07:14 AM   #5
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Original Poster
Rep: Reputation: 15
I first do a flush:

Quote:
# iptables --table nat --flush
then:

Quote:
# iptables -t nat -A POSTROUTING -o eth2 -j SNAT --to MY.PUBLIC.IP.X

still it doesnt work.

Last edited by pin_bk; 03-22-2005 at 07:16 AM.
 
Old 03-22-2005, 07:25 AM   #6
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Original Poster
Rep: Reputation: 15
When I use SNAT instead of MASQUERADE for LAN1 - 10.40.0.0 it works:

Quote:
iptables -t nat -A POSTROUTING -o eth2 -j SNAT --to 10.0.0.80
But for the LAN2 - 192.168.1.0 it dowsnt.
 
Old 03-22-2005, 07:35 AM   #7
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

here's what I use :
iptables -t nat -I POSTROUTING -o $EXT_IFACE -s $LAN_INT -j MASQUERADE
iptables -t nat -I POSTROUTING -o $EXT_IFACE -s $LAN_DMZ -j MASQUERADE

I just don't know why I didn't use only
iptables -t nat -I POSTROUTING -o $EXT_IFACE -j MASQUERADE

Maybe I tried and it didn't work... I don't remember
 
Old 03-22-2005, 07:42 AM   #8
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Rep: Reputation: 100Reputation: 100
I think it would be nice to write a diagram of your network ^^.
 
Old 03-22-2005, 07:45 AM   #9
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Original Poster
Rep: Reputation: 15
ADSL_Router(10.0.0.138)--SWITCH--Server[eth2(10.0.0.80)-eth1(10.40.0.10)-eth0(192.168.1.2)]
 
Old 03-22-2005, 10:01 AM   #10
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Rep: Reputation: 100Reputation: 100
Well i can't help you anymore... I have build some network like yours, but snat always did the trick!! Hope some guru overhere will help ya!
 
Old 03-22-2005, 12:57 PM   #11
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Original Poster
Rep: Reputation: 15
thanx Linux.tar.gz , anyone else?
 
Old 03-22-2005, 01:26 PM   #12
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Original Poster
Rep: Reputation: 15
Should I maybe add some special route table for the 192.168.1.0 lan? Since SNAT works with 10.40.0.0 network.........
 
Old 03-23-2005, 07:01 AM   #13
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Original Poster
Rep: Reputation: 15
My ADSL ROUTER can operate in BRIDGE Mode. Would it be better for me to put it in bridge mode, so I would have my public IP address on 10.0.0.80 or eth2 ?!?!
 
Old 03-23-2005, 07:13 AM   #14
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi
As for what I understand of your problem, it's not a routing issue, since your routes to both internal networks are similar.
Bridging won't solve your problem since the issue is before this on your Linux router...

I've got 2 (stupid) quesitons :
Are the correct gateways defined on your hosts on the non-working netw ?
Don't you have some firewall rules that would block the non-working netw ?

Last edited by fr_laz; 03-23-2005 at 07:15 AM.
 
Old 03-23-2005, 07:57 AM   #15
pin_bk
Member
 
Registered: Jan 2004
Posts: 45

Original Poster
Rep: Reputation: 15
The gateway on the nonworking net is correct, and the firewall rules are the same for both lans, I just blocked ports via iptables.
 
  


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
Configuring SUSE 10 with 2 NICs as gateway/DHCP Samhein Linux - Networking 3 11-24-2005 11:05 AM
Linux Gateway+Two NICS+Router+HOWTO pin_bk Linux - Networking 11 09-07-2004 12:29 PM
can't get nics working, on gateway evilchild Slackware 3 03-28-2004 07:18 PM
How do I connect dual nics in firewall to the gateway? scoobadiver Linux - Newbie 3 01-12-2004 05:03 PM
Setting up Redhat squid gateway with dual NICs wrathyimp Linux - Networking 13 06-12-2003 11:54 PM

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

All times are GMT -5. The time now is 09:02 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