LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 04-15-2009, 06:55 PM   #1
wastingtime
Member
 
Registered: Sep 2004
Posts: 77

Rep: Reputation: 16
how to set iptables to forward all on an aliased ip address


I have three machines on three networks

192.x.x.x
10.x.x.x
172.x.x.x

The routers are set to forward communication between 192. network and 10. network, and between the 10. network and the 172. network.

However, there's not routing between 192. and 172.

I want to fix that by using a machine on the 10. network to forward communication between the other two networks.

The machine has one etherent connection eth0 whose address is 10.1.1.11
I set up an aliased ip address eth0:0 to be 10.1.1.12 using
Quote:
ifconfig eth0:0 10.1.1.12
Then I tried to set forwarding rules the 10. machine such that 10.1.1.12 address will provide access to the machine 172.1.1.55 as follows
Quote:
# iptables -t nat -A PREROUTING -d 10.1.1.12 -j DNAT --to-destination 172.1.1.55
The default policies for all chains is ACCEPT.

I then try to access 10.1.1.12 from 192.1.1.20 expecting it to actually access 172.1.1.55 ; it does not work

What am I missing?

Last edited by wastingtime; 04-16-2009 at 01:42 AM.
 
Old 04-15-2009, 07:23 PM   #2
gmendoza
LQ Newbie
 
Registered: Nov 2007
Distribution: Ubuntu, Debian, Slackware
Posts: 6

Rep: Reputation: 1
Before we can give you an answer...

1. Do you have three routers with each of these three networks behind them?

For example:

Router 1 inside interface: 192.168.0.0/24
Router 2 inside interface: 10.0.0.0/8
Router 3 inside interface: 172.16.0.0/16

2. If there are three routers, what connects the three routers together? Do they each share an external interface on a common switch with a different address space?

3. Or do you have two routers, each with a 192.x.x.x and 172.x.x.x on their inside interfaces... and both of their outside interfaces connected to a switch with your Linux host on the same 10.x.x.x network.

If this is the case, I'm assuming you're trying to configure what's called router-on-a-stick. In which case, you shouldn't have to NAT, just route. This would also beg the question, why not just add the appropriate routes pointing to the respective outside interfaces on each of the routers?

Last edited by gmendoza; 04-15-2009 at 07:37 PM.
 
Old 04-15-2009, 07:31 PM   #3
wastingtime
Member
 
Registered: Sep 2004
Posts: 77

Original Poster
Rep: Reputation: 16
Yes
Router 1 inside interface: 192.168.0.0/24
Router 2 inside interface: 10.1.1.0/24
Router 3 inside interface: 172.1.1.0/24
Router 1 connects to router 2 over site-to-site vpn
I don't know how router 2 connects to router 3

Last edited by wastingtime; 04-15-2009 at 09:01 PM.
 
Old 04-16-2009, 01:42 AM   #4
wastingtime
Member
 
Registered: Sep 2004
Posts: 77

Original Poster
Rep: Reputation: 16
Found it
Quote:
# iptables -t nat -A PREROUTING -p tcp -d 10.1.1.12 --dport 22 -j DNAT --to 172.1.1.55:22
# iptables -t nat -A POSTROUTING -d 172.1.1.55 -j MASQUERADE
# echo "1" > /proc/sys/net/ipv4/ip_forward

Last edited by wastingtime; 04-16-2009 at 01:43 AM.
 
  


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
How can I forward ports with IPtables? I want to forward 80 to 8080 abefroman Linux - Networking 3 05-23-2008 11:05 AM
Nat server with iptables -P FORWARD set to DROP problem Ronin_tekorei Linux - Server 1 05-22-2008 08:22 PM
Set IP address to static from DHCP assigned address jborn Linux - Networking 4 02-02-2007 09:38 PM
Should i use the eth0 ip address of my internet ip address when applying iptables ForumKid Linux - Security 2 01-03-2002 09:54 AM
how to forward port to another address cmardhekar Linux - General 1 08-25-2001 10:08 AM


All times are GMT -5. The time now is 03:53 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration