How to Establish a Linux-to-Azure Point-to-Site VPN Connection: Protocol Compatibility and Routing Solutions


2 views

Azure Point-to-Site VPNs traditionally use IKEv2 or SSTP protocols, which creates immediate compatibility issues for Linux systems. Microsoft's official documentation primarily focuses on Windows clients, leaving Linux administrators to find alternative solutions.

The fundamental incompatibility stems from Azure's default certificate-based authentication. While OpenVPN isn't natively supported in Azure P2S, we can leverage these approaches:

# Check available VPN protocols
nmcli connection show --active | grep vpn

Though not officially documented, Azure VPN Gateways can be configured for OpenVPN:

# Sample OpenVPN configuration for Azure
client
dev tun
proto udp
remote yourgateway.azure.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-CBC
verb 3
<cert>
-----BEGIN CERTIFICATE-----
[Your certificate here]
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN PRIVATE KEY-----
[Your private key here]
-----END PRIVATE KEY-----
</key>

For systems that can handle IKEv2:

# Install StrongSwan on Ubuntu
sudo apt-get install strongswan strongswan-ikev2

# Configuration snippet for /etc/ipsec.conf
conn azure
    keyexchange=ikev2
    type=tunnel
    left=%defaultroute
    leftsubnet=0.0.0.0/0
    leftauth=eap-tls
    leftcert=client.cert.pem
    right=yourgateway.azure.com
    rightsubnet=10.0.0.0/16
    rightid=%yourgateway.azure.com
    auto=start

When dealing with connection sharing limitations:

# Enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# Basic NAT rule example
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT

Key diagnostic commands:

# Check VPN tunnel status
ipsec statusall

# Verify routes
ip route show table all

# Packet capture for debugging
tcpdump -i any -n host yourgateway.azure.com

Remember that Azure P2S certificates typically expire every 6 months, requiring regular configuration updates. For production environments, consider automating certificate renewal through Azure CLI scripts.


When attempting to bridge a Linux machine to Azure's Point-to-Site (P2S) VPN through Windows Connection Sharing (ICS), you'll encounter protocol incompatibility. Azure P2S uses SSTP or IKEv2 protocols that don't play nicely with ICS due to:

  • Certificate-based authentication requirements
  • Layer 3 routing complexities
  • Azure-specific tunnel encapsulation

Azure now supports OpenVPN protocol for P2S connections. Here's how to configure it:

# Install OpenVPN packages
sudo apt-get update && sudo apt-get install openvpn openssl

# Download Azure VPN client configuration
wget https://your-vpn-config.azure.net/GenericOpenVPN.zip
unzip GenericOpenVPN.zip -d azure-config

Azure P2S requires certificate authentication. Export these from your Windows machine:

# On Windows (PowerShell):
Export-PfxCertificate -Cert (Get-ChildItem -Path Cert:\CurrentUser\My\[AzureCertThumbprint]) -FilePath client.pfx -Password (ConvertTo-SecureString -String "YourPassword" -Force -AsPlainText)

# Convert to Linux format:
openssl pkcs12 -in client.pfx -out client.pem -nodes

Edit the OpenVPN config file from the Azure package:

# /etc/openvpn/azure.conf
client
dev tun
proto tcp
remote yourgateway.azure.com 443
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-CBC
comp-lzo
verb 3
cert client.pem
key client.pem

If connection fails, check:

  • Certificate expiration dates (Azure defaults to 1 year validity)
  • MTU size (try adding mssfix 1350 to config)
  • Azure NSG rules allowing your client IP

For organizations requiring IKEv2:

sudo apt-get install strongswan
cat << EOF > /etc/ipsec.conf
conn azure
    keyexchange=ikev2
    type=tunnel
    left=%defaultroute
    leftsubnet=0.0.0.0/0
    leftcert=client.pem
    right=yourgateway.azure.com
    rightsubnet=10.0.0.0/16
    rightid=%yourgateway.azure.com
    auto=add
EOF