Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Tore Anderson <tore@fud.no>
To: wireguard@lists.zx2c4.com
Subject: wg syncconf changes endpoint to IPv4 and removes fwmark
Date: Fri, 27 Mar 2020 22:37:48 +0100	[thread overview]
Message-ID: <e8292a70-3ba7-61ee-469c-bacb4135553f@fud.no> (raw)

While testing the patch I just sent, I stumbled across two bugs in wg syncconf:

1) The endpoint address is changed from IPv6 to IPv4 (harmless but unexpected).
2) The fwmark vanishes (harmful - the tunnel breaks completely).

The terminal log below should demonstrate these issues:

[:~] $ sudo cat /etc/wireguard/integrity.conf | sed 's/PrivateKey.*/<snip>/'
[Interface]
<snip>

Address = 10.0.237.73/24,fdab:1337:1337:237::73/64
DNS = 2001:9b1:8826::53, 2001:9b0:4:2601::53, 98.128.186.86, 155.4.89.136

[Peer]
PublicKey = ipW9/ysMc9vQbg/x7WK/udnl06+NJioWZZ4XIqz4PQY=
Endpoint = wireguard.5july.net:48574
AllowedIPs = 0.0.0.0/0, ::/0
[:~] $ sudo wg-quick up integrity
[#] ip link add integrity type wireguard
[#] wg setconf integrity /dev/fd/63
[#] ip -4 address add 10.0.237.73/24 dev integrity
[#] ip -6 address add fdab:1337:1337:237::73/64 dev integrity
[#] ip link set mtu 1420 up dev integrity
[#] mount `2001:9b1:8826::53 2001:9b0:4:2601::53 98.128.186.86 155.4.89.136' /etc/resolv.conf
[#] wg set integrity fwmark 51820
[#] ip -6 route add ::/0 dev integrity table 51820
[#] ip -6 rule add not fwmark 51820 table 51820
[#] ip -6 rule add table main suppress_prefixlength 0
[#] nft -f /dev/fd/63
[#] ip -4 route add 0.0.0.0/0 dev integrity table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] nft -f /dev/fd/63
[:~] $ sudo wg
interface: integrity
  public key: s9okCVHLskAUeQPcV7f9ThS8qOcN5WmDb8zEdl+oOnY=
  private key: (hidden)
  listening port: 40813
  fwmark: 0xca6c

peer: ipW9/ysMc9vQbg/x7WK/udnl06+NJioWZZ4XIqz4PQY=
  endpoint: [2001:9b1:8826:0:98:128:186:112]:48574
  allowed ips: 0.0.0.0/0, ::/0
  latest handshake: 8 seconds ago
  transfer: 43.33 KiB received, 46.32 KiB sent
[:~] $ sudo wg-quick strip integrity | sudo wg syncconf integrity /dev/stdin
[:~] $ sudo wg
[:~] $ sudo wg
interface: integrity
  public key: s9okCVHLskAUeQPcV7f9ThS8qOcN5WmDb8zEdl+oOnY=
  private key: (hidden)
  listening port: 50375

peer: ipW9/ysMc9vQbg/x7WK/udnl06+NJioWZZ4XIqz4PQY=
  endpoint: 98.128.186.71:48574
  allowed ips: 0.0.0.0/0, ::/0
  latest handshake: 2 minutes, 9 seconds ago
  transfer: 558.95 KiB received, 205.80 KiB sent

The endpoint changed to IPv4 and the fwmark disappeared even though the config file did not change.

The tunnel as at this point broken, passing no traffic. 'wg set integrity fwmark 51820' revives it.

I am running Fedora 31 with the latest packages (v1.0.20200102) from the jdoss/wireguard COPR.

Tore

                 reply	other threads:[~2020-03-30  2:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=e8292a70-3ba7-61ee-469c-bacb4135553f@fud.no \
    --to=tore@fud.no \
    --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).