From: Eric Dumazet <eric.dumazet@gmail.com>
To: Ashwani Wason <ashwas@gmail.com>
Cc: netdev@vger.kernel.org, tproxy@lists.balabit.hu
Subject: Re: SO_BINDTODEVICE and IP_TRANSPARENT (TPROXY)
Date: Wed, 02 Dec 2009 05:56:51 +0100 [thread overview]
Message-ID: <4B15F393.5030808@gmail.com> (raw)
In-Reply-To: <fd1a5ee40912011718r60487ce0obd88c2fbdb55fa15@mail.gmail.com>
Ashwani Wason a écrit :
> After debugging a bit into how nf_tproxy_get_sock_v4() looks up a
> listener for foreign connections using __inet_lookup_listener() and
> compute_score() I found that the problem was happening because of the
> way I had the TPROXY rules setup. Those rules work if the proxy has a
> single listening socket for INADDR_ANY. If multiple listening sockets
> must be used, one for each local address, which is the case for using
> SO_BINDTODEVICE then the TPROXY rules must also be "fully qualified"
> (with interface name [-i] and IP address thereof [--on-ip]). So the
> rules in my example change as follows...
>
> Instead of using:
>
>> iptables -t mangle -A PREROUTING -p tcp --dport 80 -j TPROXY --tproxy-mark 0x1/0x1 --on-port 4002
>
> Use:
>
> iptables -t mangle -A PREROUTING *-i eth0* -p tcp --dport 80 -j TPROXY
> --tproxy-mark 0x1/0x1 *--on-ip 192.168.0.65* --on-port 4002
> iptables -t mangle -A PREROUTING *-i eth1* -p tcp --dport 80 -j TPROXY
> --tproxy-mark 0x1/0x1 *--on-ip 192.168.1.65* --on-port 4002
>
> With these rules the listening socket was looked up correctly and the
> sk_bound_dev_if of the socket was honored.
>
> - Ashwani
>
> PS: Sorry to anyone (Jamal) who already spent any time on this.
> PPS: Copying the tproxy list in case someone else is looking for this
> stuff in the future.
Thanks a lot for sharing your discoveries :)
prev parent reply other threads:[~2009-12-02 4:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-30 23:15 SO_BINDTODEVICE and IP_TRANSPARENT (TPROXY) Ashwani Wason
2009-12-02 1:18 ` Ashwani Wason
2009-12-02 4:56 ` Eric Dumazet [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B15F393.5030808@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=ashwas@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=tproxy@lists.balabit.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).