All pastes #492386 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-17 04:32 UTC
rendered paste body
I want to take connections for a port on eth0 and nat/forward them to a port on a remote machine accessible only through eth2.

server nyl30m-8101
   eth0 169.39.214.10
   eth2 169.39.214.166

Destination ==>> 199.168.251.189 
> 
> I thought in order to make this work we need two rules - one to route  the incoming traffic to eth0
> And second to route it to the destinatio adderss 
> 
> 1- ----     I set this up but  did not work 
>              -s is the source address (Our PCs) 
> 
> iptables -t nat -A PREROUTING -p tcp -i eth0 -s 169.37.235.0/25 --sport 8603 -j DNAT --to 169.39.214.166:8603
> iptables -A FORWARD -p tcp -i eth0 -s 0/0 -d 169.39.214.166 --dport 8603 -j ACCEPT
> 
> iptables -t nat -A PREROUTING -p tcp -i eth2 -s 169.39.214.166 --sport 8603 -j DNAT --to 199.168.251.189:8603
> iptables -A FORWARD -p tcp -i eth2 -s 0/0 -d 199.168.251.189 --dport 8603 -j ACCEPT
> 
> 2 - It did not work .,. So I tried this maybe 
> 
> iptables -t nat -A PREROUTING -p tcp -i eth0 -d 169.39.214.10 --dport 8603 -j DNAT --to 169.39.214.166:8603
> iptables -A FORWARD -p tcp -i eth0 -s 0/0 -d 169.39.214.166 --dport 8603 -j ACCEPT
> 
> iptables -t nat -A POSTROUTING -p tcp -i eth2 -d 169.39.214.166 --sport 8603 -j DNAT --to 199.168.251.189:8603
> iptables -A FORWARD -p tcp -i eth2 -s 0/0 -d 199.168.251.189 --dport 8603 -j ACCEPT
> 
> 
> Well that did not work either :(   Any help with this would be appreciated ..