From: Florian Westphal <fw@strlen.de>
To: Thilo-Alexander Ginkel <thilo@ginkel.com>
Cc: netfilter@vger.kernel.org
Subject: Re: nftables: masquerading not applied consistently
Date: Wed, 8 Jul 2020 01:10:34 +0200 [thread overview]
Message-ID: <20200707231034.GC32005@breakpoint.cc> (raw)
In-Reply-To: <CANvSZQ-TM-2qs4s8QiiFQmqQG_bebn1ptwHEa3atJm7yxii_BQ@mail.gmail.com>
Thilo-Alexander Ginkel <thilo@ginkel.com> wrote:
> I have a somewhat complex VPN setup involving a Ubuntu-based VPN
> gateway ("vpn-gw") that terminates multiple VPNs based on WireGuard
> and OpenVPN. Also involved is a core router ("gw01") that performs
> routing among different VLANs comprising the LAN. One of the OpenVPN
> interfaces ("tun252") requires masquerading, which I implemented
> through the following nftables config snippet:
>
> table ip nat {
> chain postrouting {
> type nat hook postrouting priority 100; policy accept
>
> [...]
> oifname "tun252" counter masquerade
> }
> }
>
> This works fine if traffic originates on the LAN. Things start acting
> weird (i.e., no masquerading is applied when the traffic is forwarded
> to tun252) when the traffic originates on one of the WireGuard
> interfaces. The path of the packets in this case is: vpn-gw[wireguard]
> -> vpn-gw[eth0.250] -> gw01[eth0.250] -> gw01[eth0.252] ->
> vpn-gw[eth0.252] -> vpn-gw[tun252]
I.e., traffic passes vpn-gw twice? If so, that won't work.
On first pass (wireguard decap), packet x is picked up by
connection tracking and then has NAT applied to it.
As no matching NAT rule exists, the connection gets a 'do nothing'
binding. When packet comes back, it will match the existing
'do nothing' connection and the nat table is never consulted.
If thats the case, you will either need to turn off contrack for packets
coming from wireguard (use 'notrack' keyword in raw table) or, if you
need nat for this part as well, place the two rounds the packet takes in
different connection tracking zones, so that the packet coming back
from gw01/vlan252 is seen as a new flow, rather than an old packet
matching a known connection.
next prev parent reply other threads:[~2020-07-07 23:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 22:38 nftables: masquerading not applied consistently Thilo-Alexander Ginkel
2020-07-07 23:10 ` Florian Westphal [this message]
2020-07-08 7:28 ` Thilo-Alexander Ginkel
2020-07-08 10:32 ` Reindl Harald
2020-07-08 11:40 ` Thilo-Alexander Ginkel
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=20200707231034.GC32005@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter@vger.kernel.org \
--cc=thilo@ginkel.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 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.