?
Solved

Routing multiple networks with iptables

Posted on 2003-03-09
5
Medium Priority
?
414 Views
Last Modified: 2010-03-18
I have my Intranet web (192.168.10.2) server on a 192.168.10.x network. I have a Linux router setup with 2 NIC's and IPTABLES with addresses eth0 192.168.10.1 and eth1 192.168.20.1. I have the router setup where any PC on the 192.168.20.x network can browse to 192.168.20.1 and access my web browser.

My question is....How do I setup another IPTABLES Linux router so that I can connect a third LAN (192.168.30.x) to have access to my web server by routing into the 192.168.20.x LAN? For example, I would setup a Linux router box with 2 NIC's with eth0 192.168.20.2 and eth1 192.168.30.1. I want users on the 192.168.30.x LAN to browse to 192.168.30.1 and get access to my web browser. Any ideas?
0
Comment
Question by:nayen99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Expert Comment

by:mbarbos
ID: 8099141
Exactly the same way the first router was setup, but you forward 192.168.30.1 to 192.168.20.1 instead of forwarding 192.168.20.1 to 192.168.10.1. Or am I misunderstanding the question ?
0
 
LVL 6

Expert Comment

by:TheAmigo
ID: 8099717
One way is to add another rule to your first router that allows 192.168.30.x to browse, and add a rule to router2 to do DNAT on the incoming web requests to forward them on to your web server.

On router1, add:
iptable -t filter -A FORWARD -s 192.168.30.0/24 -d 192.168.10.2 -j ACCEPT

and on router2, add:
iptables -t nat -A PREROUTING -s 192.168.30.0/24 -p tcp --dport 80 -j DNAT --to-destination 192.168.10.2

Then clients on 192.168.30.x can browse to 192.168.30.1 and be silently redirected to 192.168.10.2
0
 
LVL 5

Accepted Solution

by:
Kocil earned 225 total points
ID: 8100549
> How do I setup another IPTABLES Linux router so that
> I can connect a third LAN (192.168.30.x) to have access
> to my web server by routing into the 192.168.20.x LAN?
Why do you need to route it through 20.x LAN ?
I think it is easier and faster if you just add another NIC on your first router (eth2), give it IP 192.168.30.1, and connect it to  the 30.x network.

Then you add the same IP tables rules
iptables -t nat -A PREROUTING -s 192.168.30.0/24 -p tcp --dport 80 -j DNAT --to-destination 192.168.10.2
iptable -A FORWARD -s 192.168.30.0/24 -d 192.168.10.2 -j ACCEPT

0
 
LVL 5

Expert Comment

by:Kocil
ID: 8100565
Oops ... correction for rules
Then you add the same IP tables rules
iptables -t nat -A PREROUTING -s 192.168.30.0/24 -d 192.168.30.1 -p tcp --dport 80 -j DNAT --to-destination 192.168.10.2
iptable -A FORWARD -s 192.168.30.0/24 -d 192.168.10.2 -j ACCEPT
0
 

Author Comment

by:nayen99
ID: 8110944
I thought about this problem constantly for the last few days and that is the same solution I came up with. You just confirmed it. I simply need to add another NIC to the first router and use the same basic IPTABLES rules to route into the third network. Thanks.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question