Cannot get wireguard client working on Ubuntu 20.04
The first thing you should do would be to check the connectivity between the WireGuard server and the client:
- Bring down WireGuard on both sides.
- On the server run:
nc -lu serverport
where serverport is the UDP port you used in WireGuard. - On the client run:
echo Test message | nc -4u -w1 fully.qualified.domain.server.name serverport
- The test message send by the client should be displayed on the server's terminal.
Assuming the serverport is accessible by the client, you can go on and test WireGuard.
In the server configuration [Peer]
section
AllowedIPs = 192.168.1.3/32
is correct. However, in the client configuration [Interface]
section you should enter
Address = 192.168.1.3/24
or some mask value (instead of /24
) which is the same as given in the server configuration's [Interface]
section. Please, check the server configuration [Interface]
section and determine what network mask value you have been using in the Address
line. If it is /24
, then the above value I have given should be entered in the client configuration.
Also, the
ListenPort = clientport
line in the client configuration is not needed, because that line belongs to the server configuration: It is the server that listens, not the client.
Turns out the answer was very simple (and to my shame, could not be detected by the fine people here, since I had left out the - admittedly privacy-critical - keys):
I had apparently used a private key left over from a previous install (which did not match the public key I gave to the server). Once I fixed the keys to match, the connection worked!
What I find strange though is that the wireguard on the client doesn't give any feedback that it couldn't properly establish a connection (or even better that the server did not accept its key)? That would have helped me narrow down the problem; but probably the keys should have been the first thing to double/triple-check!