How to Install and Configure WireGuard Client on Ubuntu 22.04

Estimated reading: 2 minutes 456 views


WireGuard VPN Server has been installed

My WireGuard Server: 
IP Address: 
Listen Port: 3650
Range IP VPN : 
Public and Private key is ready

How to configure WireGuard Client on Ubuntu 22.04

1. Update system

# apt update

2. Install and configuare WireGuard Client

# apt install wireguard

3. Go to ths /etc/wireguard directory

# cd /etc/wireguard/

4. Using the wg command, we will create a private key and public key

# wg genkey | tee privatekey | wg pubkey > publickey

Show content of the Private key

# cat privatekey

Show content of the Public key

# cat publickey

Please note it down for configuration in the next step

5. Install and configuare WireGuard Client

  • Create a new config file called wg0.conf
# touch wg0.conf
  • Open and new content
# nano wg0.conf

Add the following content to the configuration file:

PrivateKey = client-private-key
Address =
PublicKey = server-public-key
Endpoint = server-ip-address:3650
AllowedIPs =

Save file and exit

6. Configure Client on WireGuard Server

  • Add Client on WireGuard Server
# wg set wg0 peer PublicKey_of_the_Client allowed-ips IP_VPN_of_the_Client

  • Add the following lines to the file /etc/wireguard/wg0.conf :
## Desktop/client VPN public key ## 
PublicKey = Client VPN public key 
## client VPN IP address (note the /32 subnet) ##
AllowedIPs =

Save and exit

  • Verify config file
# wg show wg0
  • Save Configuration
# wg-quick save wg0

7. Test on Client

  • Active VPN connection on Client
# wg-quick up wg0

out put:

[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] wg set wg0 fwmark 51820

Please note: By this step your VPN is enabled on the client so it will lose connection to the client IP now

# ifconfig

8. Verify VPN connection

That’s all, friends. Currently, both the Ubuntu server and client must be securely connected using a peer-to-peer VPN called WireGuard. Let us test the connection. Enter the following ping command on your client/desktop system:

ping -c 4

Good Luck!