LogoLogo
DownloadBlog
  • Overview
  • Getting started
    • Meshnet explained
    • How to start using Meshnet
      • Using Meshnet on Windows
      • Using Meshnet on Android
      • Using Meshnet on iPhone/iPad
      • Using Meshnet on macOS
      • Using Meshnet on Linux
      • Using Meshnet on Android TV
    • How to use Meshnet securely
  • Features
    • Linking devices in Meshnet
      • Linking external Meshnet devices on Windows
      • Linking external Meshnet devices on Android
      • Linking external Meshnet devices on iPhone/iPad
      • Linking external Meshnet devices on macOS
      • Linking external Meshnet devices on Linux
      • Linking external Meshnet devices on Android TV
    • Explaining permissions
      • Remote access permissions
      • File sharing permissions
      • Traffic routing permissions
      • Local network permissions
    • Renaming devices in Meshnet
      • Renaming devices on Windows
      • Renaming devices on Android
      • Renaming devices on iPhone/iPad
      • Renaming devices on macOS
      • Renaming devices on Linux
    • Sharing files in Meshnet
      • Sharing files on Windows
      • Sharing files on Android
      • Sharing files on iPhone/iPad
      • Sharing files on macOS
      • Sharing files on Linux
      • Sharing files on Android TV
    • Routing traffic in Meshnet
      • Routing traffic from Windows
      • Routing traffic from Android
      • Routing traffic from iPhone/iPad
      • Routing traffic from macOS
      • Routing traffic from Linux
      • Routing traffic from Android TV
  • How-to guides
    • Gaming
      • How to set up a private Minecraft server with Meshnet
      • How to set up a private Stardew Valley server with Meshnet
      • How to play Quake 3 Arena over Meshnet
      • How to set up a private Team Fortress 2 server with Meshnet
      • How to set up a remote game-streaming server for Moonlight
      • How to set up a Palworld dedicated server
      • How to play Fallout: New Vegas multiplayer over Meshnet
      • How to set up a private Factorio server with Meshnet
    • Remote files and media access
      • How to set up and access shared folders
        • Configure and access shared folders on Windows
        • Configure and access shared folders on macOS
        • Configure and access shared folders on Linux
        • Access shared folders from Android
        • Access shared folders from iPhone/iPad
        • Access shared folders from Android TV
      • How to watch videos over Meshnet using Kodi
      • How to configure and access a Jellyfin media server remotely
      • How to set up a Plex media server and access it remotely
      • How to set up a remote NAS using OpenMediaVault and Meshnet
      • How to set up a remote picture library with LibrePhotos and Meshnet
      • How to use Syncthing for remote continuous file synchronization
      • How to set up a remote Airsonic music server
      • How to set up HTTP File Server for remote file access
      • How to set up a remote audiobook server
      • How to host a remote Kavita e-book server
      • How to set up and remotely access Immich using Meshnet
    • Remote device access
      • How to log in to your PC remotely over Meshnet
        • Connect to a Windows device
        • Connect to a macOS device
        • Connect to a Linux device
      • How to access remote systems over Meshnet using SSH
      • How to access your IP camera over Meshnet
      • How to use Home Assistant remotely over Meshnet
      • How to make secure macOS Time Machine backups from anywhere
      • How to use Ansible over Meshnet
      • How to access files in your NAS from anywhere without compromising its security
      • How to set up a phone as a security camera with remote access
      • How to assign custom host names to Meshnet services using Nginx proxy manager
      • How to use Proxmox VE remotely over Meshnet
      • How to set up a remotely controlled 3D printer
      • How to set up and remotely access a CasaOS server
    • Joint projects
      • How to set up an NGINX web server and remotely access it over Meshnet
      • How to use Nextcloud file syncing with Meshnet
      • How to set up pair programming using tmux
      • How to set up a Visual Studio Code server for remote development over Meshnet
      • How to host a Focalboard server for remote project management
      • How to use Meshnet for multi-screen Node.js development
      • How to use the Multi-user editing plugin in Unreal Engine over Meshnet
      • How to set up a private Mumble voice chat server
      • How to host a private Rocket.Chat server
    • Own VPN server setup
      • How to set up a VPN server through self-hosting or with DigitalOcean
      • How to create a VPN server with Microsoft Azure
      • How to create a VPN server with AWS
      • How to create a VPN server with Google Cloud
      • How to create a VPN server with Linode
      • How to create a VPN server with Hetzner
    • Network protection
      • How to set up your network protection with Pi-hole
      • How to set up your own DNS server
      • How to protect your network with AdGuard Home
      • How to use the self-hosted Whoogle search engine remotely
      • How to set up a VPN router using Meshnet
  • Troubleshooting
    • Common issues on Windows
    • Common issues on Android
    • Common issues on iPhone/iPad
    • Common issues on macOS
    • Common issues on Linux
Powered by GitBook

© 2025 Nord Security. All Rights Reserved.

On this page
  • Introduction
  • Before you begin
  • Deploy a virtual machine on Microsoft Azure
  • Method 1: Creating a VM using Azure Portal
  • Method 2: Creating a VM using Azure CLI
  • Access the virtual machine
  • Install NordVPN on the virtual machine
  • Log in to NordVPN
  • Enable Meshnet
  • Grant the traffic routing permission
  • Connect to your VPN server

Was this helpful?

  1. How-to guides
  2. Own VPN server setup

How to create a VPN server with Microsoft Azure

Learn how to create a personal VPN server using Microsoft Azure and Meshnet.

PreviousHow to set up a VPN server through self-hosting or with DigitalOceanNextHow to create a VPN server with AWS

Last updated 4 months ago

Was this helpful?

Introduction

is a cloud computing platform that provides a range of options for people looking to host their services on the cloud. Azure's extensive features and benefits make it a great choice to host a VPN server.

With Microsoft Azure, you can easily create and manage various virtual machines (VMs). Its global network of data centers ensures fast and reliable access to your services from anywhere in the world. Additionally, Azure has a flexible pricing model, offering a free subscription and allowing you to pay only for the resources you use once the free trial expires.

By using in tandem with Azure, you can turn a simple VM into a secure VPN server without any advanced configuration.

This guide showcases how you can make a VPN server from a VM hosted by Microsoft Azure using Meshnet’s traffic routing feature.

Note

Be aware that by setting up your own VPN server, you increase your online privacy but not to the same extent as when connecting to a regular VPN server provided by NordVPN, which follows a .

Before you begin

To follow this guide, you need an active Microsoft Azure account. You can sign up for free on the .

Deploy a virtual machine on Microsoft Azure

First, you need to create a VM on Azure. While this guide focuses on setting up an Ubuntu VM, Azure allows you to create Windows VMs as well.

Method 1: Creating a VM using Azure Portal

  1. Log in to your .

  2. From your Azure portal, click Virtual machines.

  3. Click Create and select Azure virtual machine.

  4. In the Instance details section, name your VM, select its region, and choose the operating system (for example, Ubuntu 22.04 LTS).

  5. Under Administrator account, select SSH public key authentication or create a password and choose the name of the administrator user of the VM.

  6. Click Review + create.

  7. Click Create.

Note

If you chose the SSH key authentication type, you will receive a Generate new key pair message after clicking the Create button. Select the Download private key and create resource option to download the private key file.

Method 2: Creating a VM using Azure CLI

Another method of managing Azure resources is the Azure Command-line interface (CLI). The Azure CLI allows you to create, deploy, and manage your Azure resources without using the internet browser. This method is highly beneficial for automation or server environments.

Install Azure CLI

Log in to Azure

Upon installing Azure CLI, log in to your Azure account by taking these steps:

  1. Open PowerShell (on Windows) or Terminal (on macOS and Linux).

  2. Run the following command to start the login process:

    az login

  3. Open the generated URL in an internet browser.

  4. Log in to your Azure account.

  5. Authenticate using the code provided in your CLI window.

Create your resource group

Azure uses resource groups to manage your VMs and their related resources. To create a resource group for your VPN server:

  1. Open PowerShell.

  2. Define the environmental variables for your VM by running the following commands:

    $env:RESOURCE_GROUP_NAME="<groupName>"
    $env:LOCATION="<region>"
    $env:VM_NAME="<vmName>"
    $env:VM_IMAGE="<imageName>"
    $env:ADMIN_USERNAME="<username>"

    Where:

    • <groupName> is a custom name for your resource group.

    • <location> is the region where your VM will be located.

      • You can check region names with the az account list-locations -o table command.

    • <vmName> is a custom name for your VM.

    • <imageName> is the name of the operating system image for your VM.

    • <username> is the name of the user account for your VM. Example

  3. Create the resource group with this command:

    az group create --name $env:RESOURCE_GROUP_NAME --location $env:LOCATION

Note

The environmental variables will be reset if you close the PowerShell window.

  1. Open Terminal.

  2. Define the environmental variables for your VM by running the following commands:

    export RESOURCE_GROUP_NAME=<groupName>
    export LOCATION=<region>
    export VM_NAME=<vmName>
    export VM_IMAGE=<imageName>
    export ADMIN_USERNAME=<user>

    Where:

    • <groupName> is a custom name for your resource group.

    • <location> is the region where your VM will be located.

      • You can check region names with the az account list-locations -o table command.

    • <vmName> is a custom name for your VM.

    • <imageName> is the name of the operating system image for your VM.

    • <username> is the name of the user account for your VM. Example

  3. Create the resource group with this command:

    az group create --name $RESOURCE_GROUP_NAME --location $LOCATION

Note

The environmental variables will be reset if you close the Terminal window.

Deploy the VM

With the environment variables defined and the resource group created, you can deploy your VM in Azure.

In PowerShell, execute the following command to create the virtual machine in Azure:

az vm create `
  --resource-group $env:RESOURCE_GROUP_NAME `
  --name $env:VM_NAME `
  --image $env:VM_IMAGE `
  --admin-username $env:ADMIN_USERNAME `
  --generate-ssh-keys `
  --public-ip-sku Standard

This command automatically generates an SSH key pair for your VM and places it in the default SSH directory (~/.ssh). Once the VM is created, you will see an output of the VM's information.

In Terminal, execute the following command to create the virtual machine in Azure:

az vm create \
  --resource-group $RESOURCE_GROUP_NAME \
  --name $VM_NAME \
  --image $VM_IMAGE \
  --admin-username $ADMIN_USERNAME \
  --generate-ssh-keys \
  --public-ip-sku Standard

This command automatically generates an SSH key pair for your VM and places it in the default SSH directory (~/.ssh). Once the VM is created, you will see an output of the VM's information.

Access the virtual machine

Once your VM is deployed, you can access it over SSH. The way to access the VM depends on which authentication method you chose while creating it.

Changing permissions for the private key

To use the SSH key for authentication, you need to set the private key’s permissions to read-only.

Windows

  1. Open PowerShell.

  2. Run the following three commands to apply the permission change, substituting </path/to/private/key> with the path to the downloaded private key:

    icacls.exe </path/to/private/key> /reset
    icacls.exe </path/to/private/key> /grant:r "$($env:username):(r)"
    icacls.exe </path/to/private/key> /inheritance:r

    Example

macOS and Linux

  1. Open Terminal.

  2. Run the following command to apply the permission change, substituting </path/to/private/key> with the path to the downloaded private key:

    chmod 400 </path/to/private/key>

    Example

    chmod 400 /Users/ventura/.ssh/UbuntuVPNServer_key.pem

Connecting over SSH

  1. Locate the public IP address of your VM.

    • If you created the VM using Azure CLI, you can run one of the following commands: For Windows in PowerShell:

      az vm show -d -g $env:RESOURCE_GROUP_NAME -n $env:VM_NAME --query publicIps -o tsv

      For macOS and Linux in Terminal:

      az vm show -d -g $RESOURCE_GROUP_NAME -n $VM_NAME --query publicIps -o tsv

  2. Run the ssh -i </path/to/private/key> <username>@<server> command in PowerShell or Terminal, where:

    • </path/to/private/key> is the location of the downloaded SSH private key.

    • <username> is the name of the administrator user of the VM.

    • <server> is the VM’s public IP address.

      Example

      ssh -i C:\Users\secretmeerkat\.ssh\UbuntuVPNServer_key.pem meerkat@20.82.123.153

  3. Type in yes and press Enter to confirm the connection.

You should now be connected to your Azure VM.

  1. Open Terminal (on Linux and macOS) or Command Prompt (on Windows).

  2. Run the ssh <username>@<server> command, where:

    • <username> is the name of the administrator user of the VM.

    • <server> is the VM’s public IP address. Example

      ssh meerkat@20.82.123.153

  3. Enter your authentication password.

  4. Type in yes and press Enter to confirm the connection.

You should now be connected to your Azure VM.

Install NordVPN on the virtual machine

Follow these steps to install NordVPN on your virtual server:

  1. Download and install the NordVPN Linux client by running the command below.

    sh <(wget -qO - https://downloads.nordcdn.com/apps/linux/install.sh)

  2. Log in to your NordVPN account.

Log in to NordVPN

You can log in to your NordVPN account without the use of a graphical user interface (GUI) in two ways:

  • By running the nordvpn login command with the --token flag

  • By running the nordvpn login command with the --callback flag

Instructions for both methods are outlined below.

Log in using a token
  1. Under Advanced settings, select Get access token.

  2. Enter the verification code sent to your email address.

  3. Under Access token, click Generate new token.

  4. In the dialog that appears, choose either a token that expires in 30 days or one that never expires, and then select Generate token.

  5. Select Copy and close.

  6. On your VM, run the nordvpn login --token <your_token> command, replacing <your_token> with the copied token. Example

    nordvpn login --token 3fe460cefb8dcf1478c92e45908cec9f9bdbadf7a456a6dfb35dc2c58ee39d5b

You should now see a welcome message.

Log in using a URL
  1. Run the following command:

    nordvpn login

  2. Open the provided link on any device in your browser.

  3. Complete the login procedure.

  4. Right-click the Continue button and select Copy link address.

  5. Run the nordvpn login --callback "<URL>" command, replacing <URL> with the previously copied link address. Example

    nordvpn login --callback "nordvpn://login?action=login&exchange_token=MGFlY2E1NmE4YjM2NDM4NjUzN2VjOWIzYWM3ZTU3ZDliNDdiNzRjZTMwMjE5YjkzZTNhNTI3ZWZlOTIwMGJlOQ%3D%3D&status=done"

You should now see a welcome message.

Tip

To preserve your token when logging out of the NordVPN app, use the nordvpn logout --persist-token command. Otherwise, your token will be revoked.

Note

If you encounter the error message “Whoops! Permission denied accessing /run/nordvpn/nordvpnd.sock,” enter sudo usermod -aG nordvpn $USER. Then, reboot your instance and log back in.

Enable Meshnet

nordvpn set meshnet on

To check your server’s Nord name and the Meshnet IP address, enter the following command:

nordvpn meshnet peer list

Example

Grant the traffic routing permission

To begin using the VPN server, you need to grant the traffic routing permission for each peer device that you want to have access to the server. Enable this permission from the server machine using the following command:

nordvpn meshnet peer routing allow <device>

Example

nordvpn meshnet peer routing allow secret.meerkat-andes.nord

Connect to your VPN server

With Meshnet enabled and the permissions granted, your peer devices should now be able to connect to the server. To connect, start routing traffic from a client device through the VM, which you can find in the list of your Meshnet peer devices.

To interact with Azure using CLI, you need to install the Azure CLI application on your device. Installation instructions for all compatible operating systems can be found on the .

You can find image names for Ubuntu Server on the .

You can find image names for Ubuntu Server on the .

You can find the public IP in the Overview section of the VM in your Azure Portal.

Locate the public IP address of your VM. It can be found in the Overview section of the VM in your Azure Portal.

On any device, log in to your dashboard and select the Meshnet (by NordVPN) card.

Upon logging in, you can by typing this command:

You will also see all of your Meshnet peer devices with their .

For more information, see the page.

For specific instructions, see the article.

should now be the same as the virtual machine’s. This way, your real public IP address is protected, and the websites you visit will see the location of your VPN server instead of your actual device.

Azure CLI documentation page
Instructions for Windows
Instructions for macOS
Instructions for Linux
Ubuntu documentation page
Ubuntu documentation page
Nord Account
enable Meshnet on Linux
corresponding permissions
Your IP address
Microsoft Azure
Meshnet
strict no-logs policy
Azure website
Azure account
Routing traffic in Meshnet
Traffic routing permissions
Creating the VM by entering its name, selecting the region, and the OS image.
Selecting the SSH public key authentication type and the username for the administrator account.
Creating environmental variables for the virtual machine in PowerShell.
Creating environmental variables for the virtual machine in Terminal.
Information of the created virtual machine.
Information of the created virtual machine.
Running the given commands in PowerShell to change permissions for the SSH key file
"Meshnet (by NordVPN)" card highlighted.
Clicking the 'Set up NordVPN manually' button.
Clicking 'Generate new token'.
Selecting the token expiry option.
Enabling Meshnet and checking the Nord name and Meshnet IP of the VM.
Selecting a traffic routing host device under the "Devices" tab.
Selecting a traffic routing host device under the "Devices" tab.
Checking the new IP address after connecting to the VPN server.