All of lore.kernel.org
 help / color / mirror / Atom feed
* local port redirect to remote IP
@ 2002-11-08  2:57 Adam Wiggins
  2002-11-12  4:43 ` Adam Wiggins
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Wiggins @ 2002-11-08  2:57 UTC (permalink / raw)
  To: netfilter


Greetings,

I need to redirect a port on the loopback device to a remote IP -
basically the reverse of a transparent Squid proxy.

The example I'm trying to get working is to make port 8000 on the
local machine connect me to www.yahoo.com:80.

I tried both DNAT and REDIRECT (not sure which is applicable here),
as follows:

[root@ash root]# iptables -F -t nat
[root@ash root]# iptables -t nat -A PREROUTING -s 127.0.0.1 -p tcp --dport 8003 -j REDIRECT --to 64.58.76.225:80
[root@ash root]# telnet localhost 8003
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
[root@ash root]# iptables -F -t nat
[root@ash root]# iptables -t nat -A PREROUTING -s 127.0.0.1 -p tcp --dport 8003 -j DNAT --to 64.58.76.225:80
[root@ash root]# telnet localhost 8003
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

The REDIRECT works on a remote machine (if I specify -s <someIP> and
then connect from that machine), so I know I must be close.  I
experimented with POSTROUTING as well, but that doesn't allow you to
specify a source IP and I need to make sure this only works when
connecting locally.

Any pointers much appreciated.

-Adam



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-11-12  4:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-08  2:57 local port redirect to remote IP Adam Wiggins
2002-11-12  4:43 ` Adam Wiggins

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.