From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Tom Hacohen <tom@stosb.com>
Cc: netfilter@vger.kernel.org
Subject: Re: nftables: masquerade sets wrong source address
Date: Wed, 14 Dec 2016 23:28:56 +0100 [thread overview]
Message-ID: <20161214222856.GA3797@salvia> (raw)
In-Reply-To: <CAEvi_o9_SJNGH-RWq6Kt+UiXVY4ozaMy3yJ2rPdV0Rbk1QrRZw@mail.gmail.com>
Hi Tom,
On Tue, Dec 13, 2016 at 01:28:41PM +0000, Tom Hacohen wrote:
> Hi,
>
> I've recently migrated from iptables (no modules loaded anymore) to
> nftables and came across a weird situation that looks like a bug to
> me.
>
> When using "masquerade" it always sets the ip address to that of one
> of my interfaces, and not per interface as one would expect.
>
> My config:
>
> flush ruleset
>
> table inet filter {
> chain input {
> type filter hook input priority 0; policy accept;
>
> iifname lo log accept
> }
> chain output {
> type filter hook output priority 0; policy accept;
> }
> }
>
> table ip nat {
> chain postrouting {
> type nat hook postrouting priority 100;
> masquerade
> }
> }
>
>
> With this, connections to localhost fail because the masquerade line
> sets the source IP to that of the wlp1s0 interface, and not of the lo
> interface.
>
> Here is output from the log:
> IN=lo OUT= MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00
> SRC=192.168.86.18 DST=127.0.0.1 LEN=60 TOS=0x00 PREC=0x00 TTL=64
> ID=64500 DF PROTO=TCP SPT=36844 DPT=8000 WINDOW=43690 RES=0x00 SYN
> URGP=0
>
> You can see how the source ip is wrong. This is from running "curl"
> trying to connect to a local http server on port 8000.
>
> Removing the masquerade line, or changing it to: "oifname wlp1s0
> masquerade" fixes it, but this is just a workaround that will fail in
> more complex situations.
>
> I would have loved to provide you with tracing information, but
> unfortunately I never got that to work for me.
>
> Tried with kernels: 4.8.12 and 4.4.35 on arch linux. Nft version is 0.6.
>
> Please let me know if there's any other info you'd like me to provide you with.
I don't remember if this behaviour has been always the case. Would you
please check what has been the behaviour in old kernels?
nftables shares this masquerade code with iptables, so you can test
this with iptables in older kernels.
Thanks.
next prev parent reply other threads:[~2016-12-14 22:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-13 13:28 nftables: masquerade sets wrong source address Tom Hacohen
2016-12-13 14:32 ` /dev/rob0
2016-12-13 14:53 ` Tom Hacohen
2016-12-14 22:28 ` Pablo Neira Ayuso [this message]
2016-12-15 11:34 ` Tom Hacohen
2016-12-15 21:29 ` Pablo Neira Ayuso
2016-12-15 22:47 ` Tom Hacohen
2016-12-16 0:04 ` Tom Hacohen
2016-12-17 14:18 ` Liping Zhang
2016-12-19 2:25 ` Liping Zhang
2016-12-20 15:16 ` Tom Hacohen
2016-12-21 2:39 ` Liping Zhang
2016-12-22 10:26 ` Tom Hacohen
2016-12-22 10:34 ` Florian Westphal
[not found] ` <CAEvi_o8wV5GNk8JvSg96kP3WdDsVsf8PubRe=K1ZiD2+nBaYTg@mail.gmail.com>
2016-12-22 22:40 ` Tom Hacohen
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=20161214222856.GA3797@salvia \
--to=pablo@netfilter.org \
--cc=netfilter@vger.kernel.org \
--cc=tom@stosb.com \
/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