Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok, so I am terrible with iptables so I need some help. Here is what I am trying to do.

I have a lan box on vlan 4 (
I have another box on vlan 9 (

My gateway for my is a linux firewall and has to remain so.
Gateway/Firewall( )

I have another box with two interfaces, one on each vlan.
Other box (eth0 ; eth1

So my flow is like this

Desktop goes to on port 80

Desktop( --> GateWay/Firewall( --> OtherBox(ETH0: --> ETH1: --> destination.

I want to do this with iptables rules on two boxes


share|improve this question
up vote 2 down vote accepted

You can do it with something like this:

Add a route on your gateway (or your desktop)
route add -host gw

Add a rule like this on the OtherBox
iptables -t nat -A POSTROUTING -i eth0 -s -d -p tcp --dport 80 -j MASQUERADE

share|improve this answer
Thanks, I like where you are going here but It did not work, here is what the windows box route looks like (desktop) Active Routes: Network Destination Netmask Gateway Interface – ThatGuy Mar 25 '13 at 16:36
Is ip forwarding allowed on the OtherBox? Check /proc/sys/net/ipv4/ip_forward And what is in the FORWARD chain? You may have to add a rule like this if your forwarding policy is not ACCEPT iptables -A FORWARD -s -d -j ACCEPT – pupkinsen Mar 26 '13 at 5:55
I got it, you da man! – ThatGuy Mar 26 '13 at 15:16
Hey I have another similar issue. – ThatGuy Jun 25 '13 at 15:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.