No keep-alives sent when private is set via PostUp
Hello,
I've encountered an edge case where no keep alives would be sent following recreating a connection with
--8<---------------cut here---------------start------------->8--- wg-quick down my-config-file
wg-quick up my-config-file
--8<---------------cut here---------------end--------------->8---
Where my-config-file contains something like:
--8<---------------cut here---------------start------------->8--- cat /gnu/store/zilv4f0jqa8nz8apqv8y3a6g0ifymxhc-wireguard-config/wg0.conf [Interface]
Address = 10.0.0.7/32
Table = auto
PostUp = /gnu/store/4cnl0h79zc599xryr5jh66d7yq643zk4-wireguard-tools-1.0.20210914/bin/wg set %i private-key /etc/wireguard/private.key
ListenPort = 51820
[Peer] #apteryx
PublicKey = JPWIbC9qMlnTkWfqGp0plOxWJ/ewOO/C9BuxIJles28= AllowedIPs = 10.0.1.1/32
Endpoint = apteryx.duckdns.org:51820 PersistentKeepalive = 25
--8<---------------cut here---------------end--------------->8---
The following command on that machine:
--8<---------------cut here---------------start------------->8--- tcpdump -n -i any port 51820
--8<---------------cut here---------------end--------------->8---
wouldn't show any traffic.
Discussing this on #wireguard (libera.chat IRC), the another| user thinks the problem could be triggered because of setting the private key in using a PostUp directive; more specifically it is believed the problem would happen when "no private key is defined when the interface comes up".
Signature · 2 lines
Thanks, Maxim
Hi Maxim,
Thanks for the bug report! I think indeed you're right about this. Can you test if this commit fixes the issue for you?
https://git.zx2c4.com/wireguard-linux/commit/?id=3ac1bf099766f1e9735883d5127148054cd5b30a
It at least satisfies the test case I added.
Until this patch hits stable kernels, you can probably work around this by changing your PostUp into a PreUp. I adjusted the man page here:
https://git.zx2c4.com/wireguard-tools/commit/?id=9d42bd1ab9d707f7a72162d36c9b37cc9bdf480e
Jason
Quoted 5 lines · Jason A. Donenfeld
Until this patch hits stable kernels, you can probably work around this by changing your PostUp into a PreUp. I adjusted the man page here:
https://git.zx2c4.com/wireguard-tools/commit/?id=9d42bd1ab9d707f7a72162d36c9b37cc9bdf480e
Er, nevermind about this part. PreUp executes before the interface is added.
Hi,
Quoted 8 lines · Jason A. Donenfeld
Quoted 5 lines · Jason A. Donenfeld
Until this patch hits stable kernels, you can probably work around this by changing your PostUp into a PreUp. I adjusted the man page here:
https://git.zx2c4.com/wireguard-tools/commit/?id=9d42bd1ab9d707f7a72162d36c9b37cc9bdf480e
Er, nevermind about this part. PreUp executes before the interface is added.
Does that mean that the example bit changed in the man page needs to be reverted?
Signature · 2 lines
Thanks, Maxim