Redirect and Masquerade

Stephan Boeni sb@bpm.ch
Thu, 31 Jan 2002 14:59:37 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0018_01C1AA67.E6AE4AA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi

I need to build the following construction:

System 1 (192.168.1.74) connects to System 2 (192.168.1.16 on Port 9991).
System 2 redirects this from eth0 incomming packages to System 3
(192.168.21.10 on Port 1972) using ippp1 and does masquerade with the own IP
address this packages.

I tryed the follwoing:

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 9991 -j REDIRECT --to
192.168.21.10:1972
iptables -t nat -A POSTROUTING -o ippp0 -j MASQUERADE

Forwarding an Masquerading does work fine, but not the Redirection. Somebody
can help me?

Stephan


------=_NextPart_000_0018_01C1AA67.E6AE4AA0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2712.300" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial=20
size=3D2>Hi</FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial size=3D2>I need =
to build the=20
following construction:</FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial size=3D2>System =
1=20
(192.168.1.74) connects to System 2 (192.168.1.16 on Port 9991). System =
2=20
redirects this from eth0 incomming packages to System =
3&nbsp;(192.168.21.10 on=20
Port 1972)&nbsp;using ippp1&nbsp;and&nbsp;does masquerade with the own =
IP=20
address this packages.</FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial size=3D2>I =
tryed the=20
follwoing:</FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3D"Courier New" =
color=3D#800000=20
size=3D2>echo 1 &gt; /proc/sys/net/ipv4/ip_forward</FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002><FONT size=3D2><SPAN=20
class=3D453084513-31012002><FONT face=3D"Courier New" color=3D#800000 =
size=3D2>iptables=20
-t nat -A PREROUTING -i eth0 -p tcp --dport 9991 -j REDIRECT --to=20
192.168.21.10:1972</FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002><FONT size=3D2><SPAN=20
class=3D453084513-31012002></SPAN><FONT face=3D"Courier New" =
color=3D#800000>iptables=20
-t nat -A POSTROUTING -o ippp0 -j MASQUERADE</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial =
size=3D2>Forwarding an=20
Masquerading does work fine, but not the Redirection. Somebody can help=20
me?</FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D453084513-31012002><FONT face=3DArial=20
size=3D2>Stephan</FONT></SPAN></DIV>
<DIV><SPAN class=3D453084513-31012002></SPAN>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0018_01C1AA67.E6AE4AA0--