Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Brian <vger-list@sd85.net>
To: matthias@urlichs.de
Cc: wireguard@lists.zx2c4.com
Subject: Re: Question about AllowedIPs and proper "mesh" setup
Date: Thu, 8 Nov 2018 14:33:06 -0500	[thread overview]
Message-ID: <3e605cc1-1951-5179-5009-87ebe4b4fcc8@sd85.net> (raw)
In-Reply-To: <CAD-Ua_gLEPjZ9ufHnLtPM-eqAj+t1pN0uFbOpx3zobF5oHSPDw@mail.gmail.com>

If you're familiar with iptables at all, this was my solution:

1) On your peer's nat table, enable masquerading on your wg interface
(you can do this as a PostUp in your wg config):

iptables -A POSTROUTING -o wg0 -j MASQUERADE

2) On peers, enable packet forwarding in sysctl if necessary:

net.ipv4.conf.wg0.forwarding = 1  (or just net.ipv4.conf.all.forwarding = 1)

3) On your laptop, pick the peer you want to connect to and put the
whole range of your wireguard IP space as its AllowedIPs.  The other
peers don't need to be in your laptop's wireguard config at all.


Once you do that, your laptop will send all its traffic to the peer you
chose, which will then act as a router and "route" the packets back into
its wireguard interface and to the intended other peer.

You can even go over multiple hops this way to access an entire network
connected to another peer if you have packet forwarding and masquerading
set up on both peers (the peer sharing the network needs iptables
masquerading and packet forwarding on the shared network's interface
also), and you put the destination network ip space in your laptop's
peer's AllowedIPs.

-Brian

On 11/6/18 3:41 PM, Lars Francke wrote:
> Phil, Matthias,
>
> thanks for the answers. I haven't received Matthias answer but I can
> see it in the archive.
>
> The reason I wanted to do it the way I initially described is
> laziness. I'm setting up the machines using Ansible[0]. It'd be great
> if I didn't need any special cases but it seems that that's going to
> be way easier than figuring out another way (which doesn't even seem
> to exist yet) ;-)
>
> Thank you both!
>
> Cheers,
> Lars
>
> [0] <https://github.com/opencore/ansible_wireguard> (It's not
> beautiful but it does what I need)
>
> On Tue, Nov 6, 2018 at 9:16 PM Phil Hofer <phil@sunfi.sh> wrote:
>
>     > Now I want to add an outside client into the mix (e.g. my
>     laptop). I want to be able to connect to just one of those hosts
>     and have that host forward my packages to the others.
>     > I can get it to work if I pick _one_ specific jump host but I
>     haven't managed to set it up in a way that I can connect to any of
>     them.
>
>     You might consider setting up just one of your servers
>     as a gateway for a subnet dedicated to your client machine(s).
>     Then add routes on your servers to the gateway.
>
>     For example, set up 10.0.0.1 as the gateway to 10.0.1.0/24
>     <http://10.0.1.0/24>,
>     and set your client machine up as 10.0.1.1. Machines on
>     10.0.0.0/24 <http://10.0.0.0/24> remain connected directly.
>
>     If you need to be able to route through any one of
>     your servers on an ad-hoc basis, then you'll need some
>     additional routing protocol magic, as Matthias suggested.
>
>     Cheers,
>     Phil
>
>
> _______________________________________________
> WireGuard mailing list
> WireGuard@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

  reply	other threads:[~2018-11-08 20:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06  8:01 Lars Francke
2018-11-06 20:04 ` Matthias Urlichs
2018-11-06 20:16 ` Phil Hofer
2018-11-06 20:41   ` Lars Francke
2018-11-08 19:33     ` Brian [this message]
2018-11-07  1:55 ` KeXianbin(http://diyism.com)

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=3e605cc1-1951-5179-5009-87ebe4b4fcc8@sd85.net \
    --to=vger-list@sd85.net \
    --cc=matthias@urlichs.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).