Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Roman Mamedov <rm@romanrm.net>
To: "Posegga, Joachim" <jp@sec.uni-passau.de>
Cc: "wireguard@lists.zx2c4.com" <wireguard@lists.zx2c4.com>
Subject: Re: Multiple Clients behind NAT
Date: Thu, 14 Jan 2021 15:53:50 +0500	[thread overview]
Message-ID: <20210114155350.2ce90402@natsu> (raw)
In-Reply-To: <f785012b2c5a49c7ba7f48f40b6ce62f@smith.sec.uni-passau.de>

On Wed, 13 Jan 2021 20:14:46 +0000
"Posegga, Joachim" <jp@sec.uni-passau.de> wrote:

> Dear all,
> 
> 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. 
> 
> Is this a known problem due to the UDP transport, or should multiple clients behind a NAT work in principle? 
> 
> I understand from the documentation that the server looks at the public key of the incoming packet and identifies the client. The response sent back from the server then arrives at the NAT gateway, and it should map the target port to the correct client and forward it. However, I am not very familiar with UDP over NAT, so I am wondering if this usually works without problems. If this is the case, I would know that the problem is most likely on the side of the Mikrotik server.

The NAT router will rewrite outgoing UDP port of your clients' packets when
they try to connect to other peers; for two clients on the LAN-side trying to
send from the same port, it should change that to two separate UDP ports.
Therefore remote peers will see your two clients as being on the same global
IP, but using two different ports -- and that should work normally.

Check with tcpdump on your NAT's WAN interface what actual UDP packets it
sends out. The ports also might be very different from what you specified in
WG's config, so account for that in firewalling or routing rules on remote
sides.

-- 
With respect,
Roman

  reply	other threads:[~2021-01-14 10:57 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 [this message]
2021-01-14 17:09 ` Riccardo Paolo Bestetti
2021-01-15 14:21   ` Maarten de Vries
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=20210114155350.2ce90402@natsu \
    --to=rm@romanrm.net \
    --cc=jp@sec.uni-passau.de \
    --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).