Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Maarten de Vries <maarten@de-vri.es>
To: Riccardo Paolo Bestetti <pbl@bestov.io>,
	"Posegga, Joachim" <jp@sec.uni-passau.de>,
	"wireguard@lists.zx2c4.com" <wireguard@lists.zx2c4.com>
Subject: Re: Multiple Clients behind NAT
Date: Fri, 15 Jan 2021 15:21:52 +0100	[thread overview]
Message-ID: <275695ad-bc63-01a6-18d0-6e9f410ec352@de-vri.es> (raw)
In-Reply-To: <C8J1PKLM140S.1TQXP9KUN0QDH@enhorning>


On 14-01-2021 18:09, Riccardo Paolo Bestetti wrote:
> On Wed Jan 13, 2021 at 9:14 PM CET, Posegga, Joachim wrote:
>> I am trying to connect multiple wireguard clients behind the same
>> NAT-Gateway to a Mikrotik server with a public IP. I am not yet sure
>> where exactly the problem is, but it seems that only one client at a
>> time can establish a tunnel.
> I don't know much about Mikrotik, but my guess is that it's not
> randomizing source ports for packets egressing the NAT.
>
> If that's the case, since WireGuard uses the same port for both source
> and destination, and since your clients are all connecting to the same
> server (and thus port), then your NAT can't demux incoming packets, and
> it just sends them all to the same client. (It probably picks the first
> one that sends egress packets, until it hits some inactivity time-out).

WireGuard doesn't have to use the same local port for all clients. In 
fact, if you don't give a ListenPort explicitly, an ephemeral port is 
assigned. This could theoretically still conflict between clients on 
different machines, but it is unlikely to happen in practice.

If NAT is broken, it should be fixed anyway, but letting WireGuard use 
ephemeral ports would also likely solve the problem in practice.


Kind regards,

Maarten


  reply	other threads:[~2021-01-15 14:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 20:14 Posegga, Joachim
2021-01-14 10:53 ` Roman Mamedov
2021-01-14 17:09 ` Riccardo Paolo Bestetti
2021-01-15 14:21   ` Maarten de Vries [this message]
2021-01-15 15:22     ` Riccardo Paolo Bestetti
2021-01-15 19:49       ` Posegga, Joachim

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=275695ad-bc63-01a6-18d0-6e9f410ec352@de-vri.es \
    --to=maarten@de-vri.es \
    --cc=jp@sec.uni-passau.de \
    --cc=pbl@bestov.io \
    --cc=wireguard@lists.zx2c4.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;
as well as URLs for NNTP newsgroup(s).