REDIRECT outgoing packets -- how?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 donskih@xxxxxxxxx

-- 
WBR,
 Dmitry                          mailto:donskih@xxxxxxxx



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux