WireGuard

Deploy WireGuard, a modern virtual private network (VPN) protocol designed for creating encrypted point-to-point tunnels over the internet.

The WireGuard Quick Deploy App provides two separate applications:

  • WireGuard Server. Creates a Linode and sets up a WireGuard network device named wg0. This device acts as the central hub for your WireGuard network.
  • WireGuard Client. Creates a Linode that can connect to your WireGuard server. You can deploy multiple clients to connect to the same server.

Note: You can deploy the WireGuard Server and Client apps independently. If you already have the server app running, you can deploy the client app and configure it to connect to your existing server.

1. Deploy WireGuard

Ā Estimated deployment time:Ā 2–5 minutes

Follow the deployment instructions from the Get started section to configure the app, deploy it, and verify software installation.

For information on the app-specific configurations, see the Configuration options section.

Software included

Software installed on your Linode when deploying the app.

PackageDescription
WireGuardA VPN software used to create encrypted network tunnels.
UFWA firewall utility. The port assigned during the deployment allows outgoing and incoming traffic.

Base distribution and plan

  • Supported distribution: Ubuntu 24.04 LTS
  • Recommended plans: All plan types and sizes can be used. Select a plan appropriate for your expected VPN traffic and number of users.

Configuration options

Configure the required options to deploy your instance. For additional customization, add advanced options.

The table maps the Cloud Manager UI fields to their corresponding API/CLI keys (stackscript_data) required for automated deployments.

WireGuard Server options

StackScript ID: 401706

UI field API/CLI key Description
Required options
Limited sudo user user_name Your preferred username for the limited sudo user entered without any capital letters, spaces, or special characters.
When adding a limited sudo user, the user is created with a strong generated password for your new Linode instance, and the account is assigned to the sudo group, which provides elevated permissions when running commands with the sudo prefix.
Note: For easier and more secure access with the sudo user, add an account SSH key for the Cloud Manager user during deployment and select that user as an authorized_user. Their SSH pubkey will be assigned to both the root and limited user.
Advanced options
Disable root access over SSH disable_root Applies to a limited sudo user. To block the root user from logging in over SSH, select Yes. Defaults to No.
Note: When you disable the root user from logging in over SSH and don't provide a valid Account SSH Key assigned to the authorized_user, you can still switch to the root user. To do that, log in as root via the Lish console and run cat /home/$USERNAME/.credentials to view the generated password for the limited sudo user.
WireGuard Server Tunnel Address wireguard_server_address The WireGuard server tunnel IP address and subnet in CIDR notation. Defaults to 10.0.0.1/24.
This is not the same as a private IP address that Linode can assign to your Linode instance. This address is managed by the network that WireGuard creates.
Optional data exporter Add-onsadd_onsAn option to include add-ons for your deployment. Possible values are:
  • none (default)
  • node_exporter
  • mysqld_exporter
  • newrelic

WireGuard Client options

StackScript ID: 1914317

UI field API/CLI key Description
Required options
Limited sudo user user_name Your preferred username for the limited sudo user entered without any capital letters, spaces, or special characters.
When adding a limited sudo user, the user is created with a strong generated password for your new Linode instance, and the account is assigned to the sudo group, which provides elevated permissions when running commands with the sudo prefix.
Note: For easier and more secure access with the sudo user, add an account SSH key for the Cloud Manager user during deployment and select that user as an authorized_user. Their SSH pubkey will be assigned to both the root and limited user.
WireGuard Server Public Key (Base64) wireguard_server_public_key The public key of your WireGuard server. You can find it in /etc/wireguard/server_public.key on your server instance.
WireGuard Server Endpoint (IP:51820) wireguard_server_endpoint The public IP address and port of your WireGuard server in the format IP:PORT.
Advanced options
Disable root access over SSH disable_root Applies to a limited sudo user. To block the root user from logging in over SSH, select Yes. Defaults to No.
Note: When you disable the root user from logging in over SSH and don't provide a valid Account SSH Key assigned to the authorized_user, you can still switch to the root user. To do that, log in as root via the Lish console and run cat /home/$USERNAME/.credentials to view the generated password for the limited sudo user.
WireGuard Client Tunnel IP (with /32) wireguard_client_tunnel_ip Your WireGuard client’s tunnel IP address with the /32 subnet. Defaults to 10.0.0.2/32.
Allowed IPs (comma-separated list) wireguard_allowed_ips A comma-separated list of IP addresses that should be routed through the WireGuard tunnel. Defaults to 10.0.0.1/32.
Optional data exporter Add-onsadd_onsAn option to include add-ons for your deployment. Possible values are:
  • none (default)
  • node_exporter
  • mysqld_exporter
  • newrelic

Use API, CLI, or Terraform

In addition to deploying the app to a new Linode instance via Cloud Manager, you can also use the Linode API, CLI, or Terraform. When running the operation, you need to provide the StackScript ID, supported Linux distribution, and app-specific fields along with the standard Linode deployment configurations.

Note: Generate a personal access token to authenticate your API, CLI, or Terraform requests.

WireGuard Server

curl --location 'https://api.linode.com/v4/linode/instances' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer abc123def456hij789klm' \
  --data-raw '{
    "region": "us-east",
    "type": "g6-standard-2",
    "image": "linode/ubuntu24.04",
    "label": "my-wireguard-server-one-click-app",
    "root_pass": "@C0mpl3x#P@ssw0rd",
    "stackscript_id": 401706,
    "stackscript_data": {
      "user_name": "jsmith"
    }
  }'
linode-cli linodes create \
  --region us-east \
  --type g6-standard-2 \
  --label my-wireguard-server-one-click-app \
  --image linode/ubuntu24.04 \
  --root_pass @C0mpl3x#P@ssw0rd \
  --stackscript_id 401706 \
  --stackscript_data '{"user_name":"jsmith"}'
resource "linode_instance" "my-linode" {
  region         = "us-east"
  type           = "g6-standard-2"
  label          = "my-wireguard-server-one-click-app"
  image          = "linode/ubuntu24.04"
  root_pass      = "@C0mpl3x#P@ssw0rd"
  stackscript_id = 401706
  stackscript_data = {
    "user_name" = "jsmith"
  }
}

WireGuard Client

curl --location 'https://api.linode.com/v4/linode/instances' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer abc123def456hij789klm' \
  --data-raw '{
    "region": "us-east",
    "type": "g6-standard-2",
    "image": "linode/ubuntu24.04",
    "label": "my-wireguard-client-one-click-app",
    "root_pass": "@C0mpl3x#P@ssw0rd",
    "stackscript_id": 1914317,
    "stackscript_data": {
      "user_name": "jsmith",
      "wireguard_server_public_key": "1+ab23cd45e67FGh890iJklM+123nOpQrs45t6=",
      "wireguard_server_endpoint": "123.1.123.0:51820"
    }
  }'
linode-cli linodes create \
  --region us-east \
  --type g6-standard-2 \
  --label my-wireguard-client-one-click-app \
  --image linode/ubuntu24.04 \
  --root_pass @C0mpl3x#P@ssw0rd \
  --stackscript_id 1914317 \
  --stackscript_data '{"user_name":"jsmith", "wireguard_server_public_key":"1+ab23cd45e67FGh890iJklM+123nOpQrs45t6=", "wireguard_server_endpoint":"123.1.123.0:51820"}'
resource "linode_instance" "my-linode" {
  region         = "us-east"
  type           = "g6-standard-2"
  label          = "my-wireguard-client-one-click-app"
  image          = "linode/ubuntu24.04"
  root_pass      = "@C0mpl3x#P@ssw0rd"
  stackscript_id = 1914317
  stackscript_data = {
    "user_name"                   = "jsmith"
    "wireguard_server_public_key" = "1+ab23cd45e67FGh890iJklM+123nOpQrs45t6="
    "wireguard_server_endpoint"   = "123.1.123.0:51820"
  }
}

2. Configure WireGuard

Server-side configuration

The WireGuard Server deployment creates these files on the instance:

  • /etc/wireguard/server_private.key. The server’s private key.
  • /etc/wireguard/server_public.key. The server’s public key.
  • /etc/wireguard/wg0.conf. The server’s WireGuard configuration file.

The initial wg0.conf looks like this:

[Interface]
PrivateKey = <server-private-key>
Address = <server-tunnel-address>
ListenPort = <listen-port>

Client-side configuration

The WireGuard Client deployment creates these files on the instance:

  • /etc/wireguard/client_private.key. The client’s private key.
  • /etc/wireguard/client_public.key. The client’s public key.
  • /etc/wireguard/wg0.conf. The client’s WireGuard configuration file.

The initial wg0.conf looks like this:

[Interface]
PrivateKey = <client-private-key>
Address = <client-tunnel-ip>
MTU = 1420
DNS = 8.8.8.8

Add clients to a server

To add a new client to your WireGuard server:

  1. Deploy a new WireGuard Client instance and copy its public key.

    cat /etc/wireguard/client_public.key
  2. On the WireGuard Server instance, edit its /etc/wireguard/wg0.conf file.

    sudo nano /etc/wireguard/wg0.conf
  3. Add a [Peer] section with the client public key and allowed client tunnel IP.

    [Peer]
    PublicKey = <client-public-key>
    AllowedIPs = <client-tunnel-ip>
  4. Restart the WireGuard Service on the server.

    sudo systemctl restart wg-quick@wg0
    sudo wg-quick down wg0
    sudo wg-quick up wg0

Test the connection

To test the connection between your WireGuard Client and Server:

  1. From the client instance, ping the server’s tunnel IP.

    ping <server-tunnel-ip>
  2. Check the WireGuard connection status.

    The output displays the WireGuard interface and peer status. Verify that the peer is listed and that the latest handshake shows a recent time indicating that the client is connected and communicating with the server. The transfer values show the amount of data exchanged through the VPN tunnel.

    sudo wg show
     interface: wg0
       public key: <server-public-key>
       private key: (hidden)
       listening port: 51820
    
     peer: <client-public-key>
       endpoint: <client-ip>:<port>
       allowed ips: <client-tunnel-ip>
       latest handshake: 1 minute, 17 seconds ago
       transfer: 98.86 KiB received, 43.08 KiB sent

Additional resources

For more information about the installed packages, see their official documentation.

šŸ“˜

Note that we can't vouch for the accuracy or timeliness of externally hosted resources.


Did this page help you?