All of lore.kernel.org
 help / color / mirror / Atom feed
* How to use TROXY target only for specific outgoing interface
@ 2013-01-13  8:54 Sebastian Poehn
  2013-01-13 11:30 ` Jan Engelhardt
  0 siblings, 1 reply; 8+ messages in thread
From: Sebastian Poehn @ 2013-01-13  8:54 UTC (permalink / raw)
  To: netfilter

I want to run a tcp transparent proxy ( with TPROXY ) processing only traffic outgoing a specific interface. That's what my setup looks like:
                                                      
                                                        
                   lan1 ############                                
    local net 1 <-------#  ROUTER  # wan                            
                        #    +     #-------------> internet                       
    local net 2 <-------#  TPROXY  #                            
                   lan2 ############                                
                                                        
Local traffic to lan1 and lan2 shall not be proxied, traffic to wan shall be proxied.
Other routers may be connected to the local networks, so we can not match for any destination netmasks.

The TPROXY target requires being entered in PREROUTING chain. Naturally the outgoing interface is only known after routing (POSTROUTING),
but then it's to late for TPROXY.

I was already thinking of possible solutions but all look more or less quirky to me (just pseudo calls, please do not insist on correctness ;-)

Solution 1 (run the stack twice):
ip link add dev loopback name tprox
iptables -A POSTROUTING -o wan -j ROUTE -oif tprox
iptables -A PREROUTING -i tprox -j TPROXY

Solution 2 (do it on your own):
iptables -A PREROUTING -j NFQUEUE
Use a small homebrew program using destination address and performing route lookup. If outgoing interface is wan mark packet and NF_REPEAT.
iptables -A PREROUTING --match-mark X -j PROXY

Solution 3 (just another idea):
TPROXY requires a ip route add local 0.0.0.0/0 (deliver everything locally).
If you'd jump to a the regular routing table traffic will not be proxied.
Unfortunately policy routing (ip rule *) can not 'match' for an outgoing interface (because the route lookup has not happened yet).

It would be great if you could give me any hints.

Greetings
Sebastian Poehn
---


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

end of thread, other threads:[~2013-01-15 18:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-13  8:54 How to use TROXY target only for specific outgoing interface Sebastian Poehn
2013-01-13 11:30 ` Jan Engelhardt
2013-01-13 16:39   ` Sebastian Poehn
2013-01-13 22:33     ` Eliezer Croitoru
2013-01-14 19:12       ` Sebastian Poehn
2013-01-15 12:02         ` Eliezer Croitoru
2013-01-15 18:37           ` Sebastian Poehn
2013-01-15 18:54             ` Eliezer Croitoru

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.