REDIRECT outgoing packets -- how?
Hi everyone.
I am trying to make some outgoing IP packets (from my linux box itself, not forwarded) be redirected to a port on localhost. And it doesn't work just because any such packet can be caught by a NAT rule only after "routing decision". So even NAT-ed packets leave the box anyway.
Example:
I want TCP packets from (localhost):10000 to (any_host):80 be redirected to (localhost:8080).
I could use
iptables -t nat -A PREROUTING -p tcp -s 12.34.56.78 --sport 10000 \ --dport 80 -j DNAT --to-destination 12.34.56.78:8080
but it doesn't work (and, it shouldn't) -- for only POSTROUTING and OUTPUT chains are available for outgoing packets.
(By the way, REDIRECT for local packets (originally from and to localhost) works fine)
Is there any other way to DNAT/REDIRECT outgoing packets to localhost?
System: RedHat 7.2 (2.4.7-10), iptables 1.2.6a
Thanks in advance for assistance.
P.S. Please CC: your reply to [email protected].
Signature · 2 lines
WBR, Dmitry mailto:[email protected]
Quoted 2 lines · --- "Dmitry L. Donskih
Is there any other way to DNAT/REDIRECT outgoing
packets to localhost?
There is an option during compiling the kernelIP_NF_NAT_LOCAL to enable NAT on locally generated connections.
Do let us know if you can manage with this.
=====
Regards,
Kiran Kumar Immidi
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html