Configure WireGuard client on Ubuntu 24.04

To set up a WireGuard client on Ubuntu 24.04 using your client.conf file, follow these steps:

Install WireGuard

Run the following command to install WireGuard on Ubuntu:

sudo apt update
sudo apt install wireguard

Place Your client.conf File

Move your client.conf file to the correct location:

sudo mv client.conf /etc/wireguard/wg0.conf
sudo chmod 600 /etc/wireguard/wg0.conf

Note: The name wg0.conf is important because WireGuard will use it when starting the interface.

Start the WireGuard Client

Use the following command to bring up the WireGuard interface:

sudo wg-quick up wg0

To check if the connection is active, run:

wg
ip a show wg0

Enable WireGuard on Boot (Optional)

If you want the WireGuard client to start automatically on boot, enable the service:

sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0

Verify Connection

Try pinging a private IP from your WireGuard network or a public IP (if your VPN routes internet traffic):

ping -c 4 8.8.8.8

Ping for public IP should provide output like next one:

$ ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=31.2 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=34.0 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=32.9 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=55 time=30.7 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 30.677/32.191/33.985/1.336 ms

If you experience connectivity issues, check logs using:

sudo journalctl -u wg-quick@wg0 --no-pager --lines=50