WireGuard Archive on lore.kernel.org
 help / color / Atom feed
From: Michael Brookes <mgsb81@gmail.com>
To: "Mantas Mikulėnas" <grawity@gmail.com>, wireguard@lists.zx2c4.com
Subject: Re: Explanation of multiple addresses in config
Date: Fri, 10 Jan 2020 11:22:12 +0000
Message-ID: <CABfcST9__kJ8Z+ED6BaWB0psJB8qaTwtnh=GHPf8iRrn-B7bJg@mail.gmail.com> (raw)
In-Reply-To: <CAPWNY8VCYCUy7B_6D-WbPFcAYVopO9D97Ykp_35MdKQUk_Z26Q@mail.gmail.com>

Thanks very much, your response helped me understand what was
happening and fixed it.
I understand the concept of AllowedIPs, but expected that when doing
wg-quick up it would install all the routes as needed, if I explain
with a config called allpeer.conf:

PrivateKey = private
Address =
Address =
Address =

PublicKey = olmRgZ8zHuq+ms8MYBflOXQscj9icsKo99UmSuwqWAA=
AllowedIPs =
Endpoint = ep1:51820
PersistentKeepalive = 25

PublicKey = PemOwzCRmpCOL+crUm5rK63vYhh5ibPflJbEhtbJLCC=
AllowedIPs =,,
Endpoint = ep2:51820
PersistentKeepalive = 25

PublicKey = DAAEZhn4xMkURkHllFmYSkfeQpaMXPxUHDJH6FybsEE=
AllowedIPs =
Endpoint = ep3:51820
PersistentKeepalive = 25

PublicKey = m+qU4tNSNXzMINohA1rr66aqUX6qVFjZhKAstZOqlDD=
AllowedIPs =,
Endpoint = ep4:51820
PersistentKeepalive = 10

Doing wg-quick up allpeer.conf I get these routes installed: dev allpeer scope link dev allpeer proto kernel scope link src dev allpeer proto kernel scope link src dev allpeer scope link dev allpeer scope link dev allpeer scope link dev allpeer scope link dev allpeer proto kernel scope link src

Which makes the peer with endpoint ep4 work, the others do not due to
packets using the wrong source address as explained in the OP.

If I remove these routes: dev allpeer scope link dev allpeer scope link dev allpeer scope link dev allpeer scope link

and manually add routes like you suggested, for example:

ip route add dev allpeer src
ip route add dev allpeer src

all peers work, which is great.

Many thanks again

On Thu, 9 Jan 2020 at 06:58, Mantas Mikulėnas <grawity@gmail.com> wrote:
> On Thu, Jan 9, 2020 at 8:04 AM Michael Brookes <mgsb81@gmail.com> wrote:
>> Hello
>> The manpage for wg-quick states one can use Address multiple times in
>> the Interface section of a config.  I've tried this but it yields
>> unexpected results.  Here is my config which I'm using on my Ubuntu
>> laptop:
>> [Interface]
>> PrivateKey = <key>
>> Address =
>> Address =
>> [Peer]
>> PublicKey = FgVLScjX29jwnXXbHStFpNKcFqbaiNK6LuSWFglrWCo=
>> AllowedIPs =,
>> Endpoint = endpoint1:51820
>> PersistentKeepalive = 10
>> [Peer]
>> PublicKey = itXrReVj+wuecrSs+VNnEEkpc7wHb8QhXQtMQUBrOj8=
>> AllowedIPs =,
>> Endpoint = endpoint2:51820
>> PersistentKeepalive = 25
>> wg-quick up <config> gives me an interface with both addresses
>> assigned, is listed first, listed second in
>> the ip addr output.
>> Running tcpdump in parallel on both peer endpoints and my latop, I
>> ping an address in the ranges the second peer lists in its AllowedIPs,
>> for example
>> tcpdump on the wireguard interfaces shows the following:
>> -> : ICMP echo request
>> I can see the peer itXrReV... receiving the echo request but it's
>> coming from the first Address listed in the config and endpoint2 only
>> has 10.88/16 addresses in it's AllowedIPs.
>> Any insight into what's happening would be gratefully received, I've
>> tried asking a couple of times but not had any feedback, I suspect I
>> am fundamentally misunderstanding something here.
> Honestly this sounds quite normal. The kernel's network stack chooses the source address without any internal knowledge about WireGuard's configuration.
> I think you're confused about the purpose of WireGuard's AllowedIPs=. It only defines acceptable *remote* addresses for that peer (destinations for outbound, sources for inbound); it does not restrict what *local* address you will use.
> You can tell Linux to prefer one source address or the other, by adding routes with the 'src' keyword in `ip route` (RTA_PREFSRC attribute). For example:
> ip route add dev wg0 src
> ip route add dev wg0 src
> --
> Mantas Mikulėnas
WireGuard mailing list

      parent reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30 10:16 Michael Brookes
     [not found] ` <CAPWNY8VCYCUy7B_6D-WbPFcAYVopO9D97Ykp_35MdKQUk_Z26Q@mail.gmail.com>
2020-01-10 11:22   ` Michael Brookes [this message]

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABfcST9__kJ8Z+ED6BaWB0psJB8qaTwtnh=GHPf8iRrn-B7bJg@mail.gmail.com' \
    --to=mgsb81@gmail.com \
    --cc=grawity@gmail.com \
    --cc=wireguard@lists.zx2c4.com \


* 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 \
	public-inbox-index wireguard

Example config snippet for mirrors

Newsgroup available over NNTP:

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