WireGuard Archive on lore.kernel.org
 help / color / Atom feed
From: Henning Reich <henningreich@gmail.com>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: Overlapping AllowedIPs Configuration
Date: Sat, 11 May 2019 17:19:42 +0200
Message-ID: <CAOAVeL3Vqr9GvomZFJafmTky-r_QmcymE0CB_ZpZHOiu=U_1aA@mail.gmail.com> (raw)
In-Reply-To: <20190506210827.2h4nzjxjpmwg7kpa@yavin>

[-- Attachment #1.1: Type: text/plain, Size: 2536 bytes --]

No, I think its correct behaviour.
If you have overlapping networks  the more specific route is preferred.
10.10.10.0/24 overrule 10.10.0.0/16.
If the subnets are the same, the last one is the more specific (because
most recent one) and should be used.

And in germany, we say (literal translation): You're allowed to shoot
yourself in the knee.
(to be self-defeating) :-)



Aleksa Sarai <cyphar@cyphar.com> schrieb am Sa., 11. Mai 2019, 15:09:

> Hi all,
>
> I just found out that WireGuard apparently allows you to configure an
> interface that has peers with overlapping AllowedIPs ranges -- which
> obviously won't work with cryptokey routing -- but additionally is
> strange since I feel this should cause an error when configuring the
> interface.
>
> In my case, I accidentally used /32 when generating the IPv6 addresses
> of my clients and ended up with a config like:
>
>   [Interface]
>   Address = 10.13.37.1/32,fd00:dead:beef:cafe::1/64
>   ListenPort = 51820
>   PrivateKey = [key]
>
>   # Peer A.
>   [Peer]
>   PublicKey = [pub]
>   PreSharedKey = [psk]
>   AllowedIPs = 10.13.40.1/32,fd00:dead:beef:1000::/32
>
>   # Peer B.
>   [Peer]
>   PublicKey = [pub]
>   PreSharedKey = [psk]
>   AllowedIPs = 10.13.41.1/32,fd00:dead:beef:1001::/32
>
> This config is wrong (because both peers have overlapping addresses
> specified for AllowedIPs), but wireguard will happily accept it:
>
>   % wg-quick up wg-foo
>   [#] ip link add wg-yavin type wireguard
>   [#] wg setconf wg-yavin /dev/fd/63
>   [#] ip address add 10.13.37.1/32 dev wg-yavin
>   [#] ip address add fd00:dead:beef:cafe::1/64 dev wg-yavin
>   [#] ip link set mtu 1420 up dev wg-yavin
>   [#] ip route add fd42:dead::/32 dev wg-yavin
>   [#] ip route add 10.13.41.1/32 dev wg-yavin
>   [#] ip route add 10.13.40.1/32 dev wg-yavin
>
> This configuration results in only one of the peers actually being given
> the IPv6 range, but I feel like "wg setconf" should've rejected this
> configuration.
>
>   % wg
>   interface: wg-foo
>     public key: [pub]
>     private key: (hidden)
>     listening port: 51820
>
>   peer: [peer A]
>     preshared key: (hidden)
>     allowed ips: 10.13.40.1/32
>
>   peer: [peer B]
>     preshared key: (hidden)
>     allowed ips: 10.13.41.1/32, fd42:dead::/32
>
> --
> Aleksa Sarai
> Senior Software Engineer (Containers)
> SUSE Linux GmbH
> <https://www.cyphar.com/>
> _______________________________________________
> WireGuard mailing list
> WireGuard@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard
>

[-- Attachment #1.2: Type: text/html, Size: 4288 bytes --]

<div dir="auto">No, I think its correct behaviour.<div dir="auto">If you have overlapping networks  the more specific route is preferred. <a href="http://10.10.10.0/24">10.10.10.0/24</a> overrule <a href="http://10.10.0.0/16">10.10.0.0/16</a>.</div><div dir="auto">If the subnets are the same, the last one is the more specific (because most recent one) and should be used.</div><div dir="auto"><br></div><div dir="auto">And in germany, we say (literal translation): You&#39;re allowed to shoot yourself in the knee.</div><div dir="auto">(to be self-defeating) :-)</div><div dir="auto"><br></div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Aleksa Sarai &lt;<a href="mailto:cyphar@cyphar.com">cyphar@cyphar.com</a>&gt; schrieb am Sa., 11. Mai 2019, 15:09:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I just found out that WireGuard apparently allows you to configure an<br>
interface that has peers with overlapping AllowedIPs ranges -- which<br>
obviously won&#39;t work with cryptokey routing -- but additionally is<br>
strange since I feel this should cause an error when configuring the<br>
interface.<br>
<br>
In my case, I accidentally used /32 when generating the IPv6 addresses<br>
of my clients and ended up with a config like:<br>
<br>
  [Interface]<br>
  Address = <a href="http://10.13.37.1/32,fd00:dead:beef:cafe::1/64" rel="noreferrer noreferrer" target="_blank">10.13.37.1/32,fd00:dead:beef:cafe::1/64</a><br>
  ListenPort = 51820<br>
  PrivateKey = [key]<br>
<br>
  # Peer A.<br>
  [Peer]<br>
  PublicKey = [pub]<br>
  PreSharedKey = [psk]<br>
  AllowedIPs = <a href="http://10.13.40.1/32,fd00:dead:beef:1000::/32" rel="noreferrer noreferrer" target="_blank">10.13.40.1/32,fd00:dead:beef:1000::/32</a><br>
<br>
  # Peer B.<br>
  [Peer]<br>
  PublicKey = [pub]<br>
  PreSharedKey = [psk]<br>
  AllowedIPs = <a href="http://10.13.41.1/32,fd00:dead:beef:1001::/32" rel="noreferrer noreferrer" target="_blank">10.13.41.1/32,fd00:dead:beef:1001::/32</a><br>
<br>
This config is wrong (because both peers have overlapping addresses<br>
specified for AllowedIPs), but wireguard will happily accept it:<br>
<br>
  % wg-quick up wg-foo<br>
  [#] ip link add wg-yavin type wireguard<br>
  [#] wg setconf wg-yavin /dev/fd/63<br>
  [#] ip address add <a href="http://10.13.37.1/32" rel="noreferrer noreferrer" target="_blank">10.13.37.1/32</a> dev wg-yavin<br>
  [#] ip address add fd00:dead:beef:cafe::1/64 dev wg-yavin<br>
  [#] ip link set mtu 1420 up dev wg-yavin<br>
  [#] ip route add fd42:dead::/32 dev wg-yavin<br>
  [#] ip route add <a href="http://10.13.41.1/32" rel="noreferrer noreferrer" target="_blank">10.13.41.1/32</a> dev wg-yavin<br>
  [#] ip route add <a href="http://10.13.40.1/32" rel="noreferrer noreferrer" target="_blank">10.13.40.1/32</a> dev wg-yavin<br>
<br>
This configuration results in only one of the peers actually being given<br>
the IPv6 range, but I feel like &quot;wg setconf&quot; should&#39;ve rejected this<br>
configuration.<br>
<br>
  % wg<br>
  interface: wg-foo<br>
    public key: [pub]<br>
    private key: (hidden)<br>
    listening port: 51820<br>
<br>
  peer: [peer A]<br>
    preshared key: (hidden)<br>
    allowed ips: <a href="http://10.13.40.1/32" rel="noreferrer noreferrer" target="_blank">10.13.40.1/32</a><br>
<br>
  peer: [peer B]<br>
    preshared key: (hidden)<br>
    allowed ips: <a href="http://10.13.41.1/32" rel="noreferrer noreferrer" target="_blank">10.13.41.1/32</a>, fd42:dead::/32<br>
<br>
-- <br>
Aleksa Sarai<br>
Senior Software Engineer (Containers)<br>
SUSE Linux GmbH<br>
&lt;<a href="https://www.cyphar.com/" rel="noreferrer noreferrer" target="_blank">https://www.cyphar.com/</a>&gt;<br>
_______________________________________________<br>
WireGuard mailing list<br>
<a href="mailto:WireGuard@lists.zx2c4.com" target="_blank" rel="noreferrer">WireGuard@lists.zx2c4.com</a><br>
<a href="https://lists.zx2c4.com/mailman/listinfo/wireguard" rel="noreferrer noreferrer" target="_blank">https://lists.zx2c4.com/mailman/listinfo/wireguard</a><br>
</blockquote></div>

[-- Attachment #2: Type: text/plain, Size: 148 bytes --]

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

  reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 21:08 Aleksa Sarai
2019-05-11 15:19 ` Henning Reich [this message]
2019-05-11 17:11   ` Aleksa Sarai
2019-05-25 18:39 ` Paul Zillmann
2019-06-06 10:09   ` Toke Høiland-Jørgensen
2019-06-07  8:05     ` Ivan Labáth
2019-06-07 10:07       ` Matthias Urlichs
2019-06-13  7:29         ` Vincent Wiemann
2019-06-07 23:58     ` Paul Zillmann
2019-06-08  7:32   ` Markus Grundmann

Reply instructions:

You may reply publically 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='CAOAVeL3Vqr9GvomZFJafmTky-r_QmcymE0CB_ZpZHOiu=U_1aA@mail.gmail.com' \
    --to=henningreich@gmail.com \
    --cc=cyphar@cyphar.com \
    --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

WireGuard Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/wireguard/0 wireguard/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 wireguard wireguard/ https://lore.kernel.org/wireguard \
		wireguard@lists.zx2c4.com zx2c4-wireguard@archiver.kernel.org
	public-inbox-index wireguard


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/com.zx2c4.lists.wireguard


AGPL code for this site: git clone https://public-inbox.org/ public-inbox