An Azure Bicep template to quickly setup your own WireGuard VPN Server.
The quickest way to setup your own modern VPN server.
WireGuard VPN is a rethink of how VPN software are designed and is receiving genuine appreciation from the community. This Azure Bicep template helps you to setup a WireGuard VPN server quickly, taking care of all the configuration steps.
Some knowledge of how Azure Bicep templates work is really helpful.
Clone the git repository.
Login to your Azure subscription
az login
(Optional Step ... In case you have multiple Azure subscriptions) List your Azure subscriptions
az account list --output table
(Optional Step ... In case you have multiple Azure subscriptions) Set your default Azure subscription to which this Bicep template will be deployed
az account set --subscription <SubscriptionId>
(Optional Step ... In case you want to validate the template) Run a what-if check
az deployment sub create --name wireguard --location eastus --template-file .\AzureWireGuard\AzureWireGuard.bicep --what-if
Deploy the Bicep template with defaults. For customization refer to this.
az deployment sub create --name wireguard --location eastus --template-file .\AzureWireGuard\AzureWireGuard.bicep
While deploying the Bicep template you can pass a parameters file
az deployment sub create --name wireguard --location eastus --template-file .\AzureWireGuard\AzureWireGuard.bicep --parameters "@AzureWireGuard\AzureWireGuard.parameters.json"
The template parameters available for customization are
Parameter | Description | Defaults |
---|---|---|
code | A string used in the resource names | Random string to avoid resource conflicts. uniqueString Based on the Subscription Id and Location |
adminUsername | Admin Username for the Virtual Machine | vmadmin |
adminPassword | Password for the Virtual Machine | Prompts during deployment |
location | Location to deploy the resources. The location specified in the az deployment command does not control the location of the resources. It is the location of the Azure Deployment |
eastus |
vmSize | Size of the Virtual Machine | Standard_DS2_v2 |
tags | Tags that are attached to the resources created | DeployedOn |
The client configuration files are named wg0-client-1.conf, wg0-client-2.conf, ..., wg0-client-9.conf and wg0-client-10.conf.
They are located in the administrator users home folder (~/).
You can use tools like scp and pscp to download the client configuration files directly from the server.
scp <admin-user>@<server-fqdn>:/home/<admin-user>/wg0-client-1.conf /local/dir/
pscp <admin-user>@<server-fqdn>:/home/<admin-user>/wg0-client-1.conf c:\local\
Example:
scp [email protected]:/home/vmadmin/wg0-client* /local/dir/
The earlier version of AzureWireGuard used Azure ARM templates. It is no longer maintained but is available on the branch named arm-retired
NOTE: Be sure to pull the latest from "upstream" before making a pull request!