Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 04-15-2009, 05:55 PM   #1
Registered: Sep 2004
Posts: 86

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

I have three machines on three networks


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
I set up an aliased ip address eth0:0 to be using
ifconfig eth0:0
Then I tried to set forwarding rules the 10. machine such that address will provide access to the machine as follows
# iptables -t nat -A PREROUTING -d -j DNAT --to-destination
The default policies for all chains is ACCEPT.

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

What am I missing?

Last edited by wastingtime; 04-16-2009 at 12:42 AM.
Old 04-15-2009, 06:23 PM   #2
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:
Router 2 inside interface:
Router 3 inside interface:

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 06:37 PM.
Old 04-15-2009, 06:31 PM   #3
Registered: Sep 2004
Posts: 86

Original Poster
Rep: Reputation: 17
Router 1 inside interface:
Router 2 inside interface:
Router 3 inside interface:
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 08:01 PM.
Old 04-16-2009, 12:42 AM   #4
Registered: Sep 2004
Posts: 86

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

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


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

All times are GMT -5. The time now is 01:51 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration