DEV Community

Cover image for Using Vultr's WireGuard Marketplace Application
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya Originally published at docs.vultr.com

Using Vultr's WireGuard Marketplace Application

WireGuard is an open-source virtual private networking (VPN) application. Vultr's WireGuard Marketplace Application deploys a preconfigured WireGuard server that supports multiple VPN clients through a single instance, so you can connect several devices and reach the internet through the server's public IP without exposing any local addresses. This guide deploys the Marketplace Application, generates client keys and peer configurations, and connects Windows, macOS, and Linux clients. By the end, you'll have client devices that reach the internet through your VPN server's single public IP.


WireGuard Features

WireGuard offers the following VPN features, enabling you to set up secure and reliable connections between devices:

  • Encrypts traffic with ChaCha20, authenticates it with Poly1305, and exchanges keys using Curve25519.
  • Runs a codebase of roughly 4,000 lines, compared to over 100,000 lines in typical kernel IPsec implementations.
  • Supports multiple client devices connecting to the same server simultaneously.
  • Supports multiple VPN interfaces for separate client groups or networks.

Deploy the WireGuard Marketplace Application

1. Log in to the Vultr Console.

2. Click Compute on the main navigation menu and click Create Instance +.

3. Select your desired instance plan, such as Dedicated CPU, and specify the compute specifications, such as 2 vCPUs and 4 GB RAM.

4. Click Configure Software to specify the system image.

5. Click Marketplace App within the Image Selection and Configuration section.

6. Enter WireGuard as the search term and select it from the search results.

7. Specify the server hostname and additional features.

8. Click Deploy and wait for the installation process to complete.

9. Open the instance's management page and verify the WireGuard application instructions including the endpoint, port, and default subnet information for connecting to the VPN server.

The application also preconfigures one client peer at the 10.1.0.2 address and hosts its client configuration at http://SERVER_IP/wireguard_conf/wg0.conf, protected by HTTP basic authentication. The following section creates an additional client at 10.1.0.3 so the two configurations do not conflict.


Generate WireGuard Client Configurations

Each WireGuard client needs its own keypair and a matching [Peer] entry on the server. Each side's [Peer] entry contains the public key of the device on the other side of the tunnel.

1. Log in to your WireGuard server using SSH:

$ ssh root@SERVER_IP
Enter fullscreen mode Exit fullscreen mode

Replace SERVER_IP with your server's public IP address.

2. Generate a new WireGuard client keypair using the wg command:

# wg genkey | tee client_private.key | wg pubkey > client_public.key
Enter fullscreen mode Exit fullscreen mode

3. Print the generated client_private.key and client_public.key files:

# cat client_private.key client_public.key
Enter fullscreen mode Exit fullscreen mode

Copy the generated keys in your output to use them in your client configurations.

EjR3L9pQ8xZ2vF1nK6mH7jW5dC0bN4sX9tY1rP2mL3g=
7qK2mN9pL4xZ1vF8nK3mH5jW6dC0bN2sX9tY1rP4mL7=
Enter fullscreen mode Exit fullscreen mode

4. List files in the /etc/wireguard directory and verify the available configurations:

# ls /etc/wireguard
Enter fullscreen mode Exit fullscreen mode

Output:

wg0.conf
Enter fullscreen mode Exit fullscreen mode

Based on the above output, wg0.conf is the available WireGuard interface configuration.

5. Open the wg0.conf file using a text editor such as nano:

# nano /etc/wireguard/wg0.conf
Enter fullscreen mode Exit fullscreen mode

6. Add a new [Peer] block with your WireGuard client's public key at the end of the file:

[Peer]
PublicKey = CLIENT_PUBLIC_KEY
AllowedIPs = 10.1.0.3/32
Enter fullscreen mode Exit fullscreen mode

Replace CLIENT_PUBLIC_KEY with the public key you generated earlier. Save and close the wg0.conf file.

7. Display the server's public key:

# wg show wg0 public-key
Enter fullscreen mode Exit fullscreen mode

The output is the server's public key. Copy it to use in the next step.

8. Create a new client1.conf file in your working directory to create a transferable client configuration:

# nano client1.conf
Enter fullscreen mode Exit fullscreen mode

9. Add the following contents to the client1.conf file:

[Interface]
PrivateKey = CLIENT_PRIVATE_KEY
Address = 10.1.0.3/32
DNS = 1.1.1.1, 8.8.8.8

[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = SERVER_IP:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
Enter fullscreen mode Exit fullscreen mode

Replace:

  • CLIENT_PRIVATE_KEY with the private key from client_private.key.
  • SERVER_PUBLIC_KEY with the value from the previous step.
  • SERVER_IP with your server's public IP address.

Save and close the client1.conf file. The above configuration specifies the WireGuard client information used to establish connections to the VPN server using its endpoint. The AllowedIPs = 0.0.0.0/0 value routes all client traffic through the VPN server.

10. Restart the WireGuard service to apply the configuration changes:

# systemctl restart wg-quick@wg0
Enter fullscreen mode Exit fullscreen mode

11. Verify that the new peer appears in the interface's configuration:

# wg show wg0
Enter fullscreen mode Exit fullscreen mode

The output lists the new peer's public key. A latest handshake entry appears only after a client connects, so it may be absent until then.


Connect WireGuard Clients to the VPN Server

WireGuard supports multiple client applications for connection to a VPN server. You can connect using the official application for your mobile device, desktop, or a Linux-based system. Before connecting a client, verify that its public key appears as a peer in the wg show wg0 output on the server.

1. Print the contents of the client1.conf file you generated earlier:

# cat client1.conf
Enter fullscreen mode Exit fullscreen mode

Copy the output.

2. On your client device, create a new file named client1.conf and paste the copied contents into it. Repeat this process for each client device you want to connect to the VPN server.


Connect Desktop WireGuard Clients

The official WireGuard application provides the same tunnel-import workflow for Windows and macOS.

1. Visit the official WireGuard Installation page.

2. Download the latest installer for your desktop operating system, such as the Windows installer, and run it to install WireGuard.

3. Open WireGuard from your applications menu.

4. Click Import tunnel(s) from file and select the client1.conf file you created earlier.

5. Click Activate to connect to your VPN server.

6. Verify that the VPN connection is successful and monitor the data transfer rates.


Connect Linux WireGuard Clients

Linux systems use the wg-quick command-line tool instead of a GUI application.

Warning: The client configuration routes all traffic through the VPN server. If you connect to the Linux client over SSH, activating the tunnel disconnects your SSH session. Run these steps from a local terminal or a console session on the client.

1. Update the package index on your Linux system:

$ sudo apt update
Enter fullscreen mode Exit fullscreen mode

2. Install WireGuard:

$ sudo apt install wireguard -y
Enter fullscreen mode Exit fullscreen mode

3. Move the client1.conf file you created earlier to the /etc/wireguard directory:

$ sudo mv client1.conf /etc/wireguard
Enter fullscreen mode Exit fullscreen mode

4. Activate the configuration to establish a tunnel connection to the VPN server:

$ sudo wg-quick up client1
Enter fullscreen mode Exit fullscreen mode

5. Verify that the client established a handshake with the server:

$ sudo wg show client1
Enter fullscreen mode Exit fullscreen mode

The output includes a latest handshake entry after the connection succeeds.

6. Enable the WireGuard client interface to run at boot:

$ sudo systemctl enable wg-quick@client1
Enter fullscreen mode Exit fullscreen mode

7. Test the connection to the VPN server's tunnel address:

$ ping -c 3 10.1.0.1
Enter fullscreen mode Exit fullscreen mode

The output reports 0% packet loss, which confirms that the client reaches the server through the tunnel.

8. Verify that the client's internet traffic leaves through the VPN server:

$ curl -4 ifconfig.me
Enter fullscreen mode Exit fullscreen mode

The output displays your VPN server's public IP address.


Next Steps

Your WireGuard server is running and your clients reach the internet through its public IP. From here you can:

  • Add more clients by repeating the keypair, [Peer], and client.conf steps with a new tunnel address such as 10.1.0.4/32
  • Narrow AllowedIPs on a client to route only specific networks through the tunnel (split tunneling) instead of all traffic
  • Review the official WireGuard documentation for advanced configuration options

For the full guide with additional tips, visit the original article on Vultr Docs.

Top comments (0)