Configure a point-to-site (P2S) VPN on Linux for use with Azure Files
Article
You can use a point-to-site (P2S) virtual private network (VPN) connection to mount your Azure file shares from outside of Azure, without sending data over the open internet. A point-to-site VPN connection is a VPN connection between Azure and an individual client. To use a P2S VPN connection with Azure Files, you'll need to configure a P2S VPN connection for each client that wants to connect. If you have many clients that need to connect to your Azure file shares from your on-premises network, you can use a site-to-site (S2S) VPN connection instead of a point-to-site connection for each client. To learn more, see Configure a site-to-site VPN for use with Azure Files.
We strongly recommend that you read Azure Files networking overview before continuing with this article for a complete discussion of the networking options available for Azure Files.
The article details the steps to configure a point-to-site VPN on Linux to mount Azure file shares directly on-premises.
Applies to
File share type
SMB
NFS
Standard file shares (GPv2), LRS/ZRS
Standard file shares (GPv2), GRS/GZRS
Premium file shares (FileStorage), LRS/ZRS
Prerequisites
The most recent version of the Azure CLI. For information on how to install the Azure CLI, see Install the Azure PowerShell CLI and select your operating system. If you prefer to use the Azure PowerShell module on Linux, you may. However, the instructions below are for Azure CLI.
An Azure file share you'd like to mount on-premises. Azure file shares are deployed within storage accounts, which are management constructs that represent a shared pool of storage in which you can deploy multiple file shares, as well as other storage resources, such as blob containers or queues. You can learn more about how to deploy Azure file shares and storage accounts in Create an Azure file share.
A private endpoint for the storage account containing the Azure file share you want to mount on-premises. To learn how to create a private endpoint, see Configuring Azure Files network endpoints.
Install required software
The Azure virtual network gateway can provide VPN connections using several VPN protocols, including IPsec and OpenVPN. This article shows how to use IPsec and uses the strongSwan package to provide the support on Linux.
If the installation fails or you get an error such as EAP_IDENTITY not supported, sending EAP_NAK, you might need to install extra plugins:
sudo apt install -y libcharon-extra-plugins
Deploy a virtual network
To access your Azure file share and other Azure resources from on-premises via a Point-to-Site VPN, you must create a virtual network, or VNet. The P2S VPN connection you'll automatically create is a bridge between your on-premises Linux machine and this Azure virtual network.
The following script will create an Azure virtual network with three subnets: one for your storage account's service endpoint, one for your storage account's private endpoint, which is required to access the storage account on-premises without creating custom routing for the public IP of the storage account that may change, and one for your virtual network gateway that provides the VPN service.
Remember to replace <region>, <resource-group>, and <desired-vnet-name> with the appropriate values for your environment.
In order for VPN connections from your on-premises Linux machines to be authenticated to access your virtual network, you must create two certificates:
A root certificate, which will be provided to the virtual machine gateway
A client certificate, which will be signed with the root certificate
The following script creates the required certificates.
The Azure virtual network gateway is the service that your on-premises Linux machines will connect to. Deploying this service requires two basic components:
A public IP address that will identify the gateway to your clients wherever they are in the world
The root certificate you created earlier that will be used to authenticate your clients
Remember to replace <desired-vpn-name-here> with the name you would like for these resources.
Note
Deploying the Azure virtual network gateway can take up to 45 minutes. While this resource is being deployed, this bash script will block the deployment from being completed.
P2S IKEv2/OpenVPN connections aren't supported with the Basic SKU. This script uses the VpnGw1 SKU for the virtual network gateway.
The Azure virtual network gateway will create a downloadable package with configuration files required to initialize the VPN connection on your on-premises Linux machine. The following script will place the certificates you created in the correct spot and configure the ipsec.conf file with the correct values from the configuration file in the downloadable package.
Network configuration and the use of Virtual Private Networks (VPNs) is integral to the success of collaborative working. In this module, we look at how to monitor and troubleshoot site-to-site and point-to-site VPNs. AZ720 AZ-720 az-720 networking