wg syncconf changes endpoint to IPv4 and removes fwmark

Tore Anderson tore at fud.no
Fri Mar 27 22:37:48 CET 2020


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


More information about the WireGuard mailing list