VPN Gateway in Azure: A Secure Tunnel Between Your Networks and the Cloud
A beginner-friendly, book-style guide to Azure VPN Gateway. Learn how encrypted tunnels connect offices, remote workers, and cloud networks, how the service works inside, and how to design, secure, scale, monitor, and troubleshoot it in production.
Imagine your company has an office in one city and a brand-new warehouse of computers in the cloud, hundreds of kilometres away. Your staff need to open files on those cloud computers as if they were sitting in the next room. The only road between the two places is the public internet, a road shared with everyone else in the world, including people who would love to read your mail. You need a way to travel that public road in a sealed, armoured vehicle that no one can open or tamper with.
That armoured vehicle is a virtual private network, usually shortened to VPN. In Microsoft Azure, the service that builds such sealed connections is called Azure VPN Gateway. It connects your on-premises networks, your remote workers, and your other Azure networks to a virtual network in the cloud, using encryption so that private data stays private while it crosses the public internet.
This guide assumes you know nothing about the subject. Every new word is explained the first time it appears, every big idea has an everyday comparison, and the chapters build step by step. By the end you will understand what VPN Gateway is, how its tunnels are built and kept alive, how to choose settings, how to make it resilient and fast, how to secure it, how it compares with other Azure connectivity options, and how to find and fix problems.
1The Problem: Connecting Two Worlds Safely
Almost every company today lives in two places at once: its own buildings and the cloud. The challenge is making those two places feel like one network without exposing anything to the open internet.
The hybrid reality
When a company first moves to the cloud, it rarely moves everything at once. Some servers, databases, and printers stay in the office or in a data centre the company owns. New applications start in the cloud. This mixture is called a hybrid setup, and it is the normal state of most organisations for years. In a hybrid setup, programs on one side need to talk to programs on the other side all day long: a cloud application reads a customer record from an office database, or an office computer opens a file from a cloud server.
Those conversations contain private information such as customer details, financial figures, and passwords. If they travelled across the internet unprotected, anyone along the route could read or alter them. At the same time, the cloud servers should not be reachable by random strangers. The goal is a private path: reachable only by the right people and machines, protected from eavesdropping.
Think of two bank branches in different cities that must move cash between them. They could hand a suitcase to a stranger and hope for the best, or build their own private railway line. Or they could hire an armoured van that uses the public roads but has locked doors, a sealed cargo area, and a driver who checks identity at both ends. A VPN is the armoured van: it shares the public road but protects what is inside.
Two main ways to connect
There are two broad approaches to linking a company network to the cloud. The first is a dedicated private line: a physical circuit rented from a telecommunications provider that never touches the public internet. It is fast and predictable, but it is expensive and takes weeks to arrange. In Azure, this is called ExpressRoute. The second approach is a VPN over the internet: ordinary internet connections, with encryption layered on top. It is cheap, it can be set up in under an hour once you know the steps, and it works from anywhere there is internet. In Azure, this is VPN Gateway.
Who needs this
Branch connections
A shop, clinic, or factory needs its local network to reach cloud applications as if they were next door.
Work from anywhere
An employee at home or in a hotel needs to reach internal systems safely from a laptop.
Moving to the cloud
A company copies data and runs old and new systems side by side during a gradual move.
Linking Azure networks
Two virtual networks, perhaps in different regions or subscriptions, must be joined privately.
Resilient connectivity
A VPN serves as the safety net if a main private line fails.
Test environments
Developers reach private test servers in the cloud without exposing them to the internet.
An illustrative example
Picture a hypothetical regional bank with a head office, twelve small branches, and a new customer-service application in Azure. Every branch connects to Azure over a VPN tunnel through its normal internet connection. The head office connects with two tunnels for safety. Remote call-centre staff connect from home with a client program on their laptops. All of the traffic is encrypted, the Azure servers have no public addresses, and the bank’s security team can show auditors exactly who can reach what. That whole picture is built with one family of Azure services, and this guide shows how.
2Core Concepts: The Networking Ideas Behind a VPN
A handful of simple networking ideas unlock everything that follows. Read this chapter slowly and the rest of the guide will feel easy.
IP addresses and networks
Every device on a network has an IP address, a number like 10.1.2.3 that works like a street address for data. Addresses are grouped into networks, and each network is written as a range using CIDR notation, which looks like 10.1.0.0/16. The number after the slash says how many of the leading bits are fixed, which in turn tells you how large the range is. A /16 holds about 65,000 addresses, a /24 holds 256, and a /27 holds 32. Smaller networks carved from a bigger one are called subnets.
Some address ranges, such as 10.0.0.0 to 10.255.255.255, 172.16.0.0 to 172.31.255.255, and 192.168.0.0 to 192.168.255.255, are private: they are reserved for use inside organisations and are not routed on the public internet. Almost every office network and every Azure virtual network uses private addresses.
An IP address is a house address. A subnet is a street. A network is a whole neighbourhood. CIDR notation is the shorthand that says “all houses numbered from here to there.” Private ranges are like internal room numbers in an office building: meaningful inside, meaningless to the postman outside.
Why overlapping addresses are a disaster
If your office uses the range 10.1.0.0/16 and your cloud network also uses 10.1.0.0/16, a computer asked to send data to 10.1.5.5 cannot tell whether that machine is down the hall or in the cloud. The two networks overlap, and a VPN cannot join them properly. Planning address ranges so they never overlap, across every office, cloud network, and remote user pool, is the single most important design step. It is also the one most often forgotten.
Routing: following the signposts
Routing is the process of deciding which way to send data so it reaches its destination. A route is a simple rule: “for destinations in this range, send the data that way.” Devices called routers keep tables of these rules. Routes can be written by hand, which is called static routing, or learned automatically from neighbours using a routing protocol, which is called dynamic routing. The most common dynamic protocol between networks is the Border Gateway Protocol (BGP).
Static routes are a paper road map that you update yourself. If a road closes, the map stays wrong until you fix it. BGP is a live traffic app: neighbours tell each other about every road change, and everyone adjusts instantly.
NAT: sharing one public address
Network Address Translation (NAT) lets many devices with private addresses share one public address when talking to the internet. A NAT device rewrites the sender address on the way out and remembers how to reverse it on the way back. NAT matters for VPNs because a VPN device behind a NAT must use a special technique, called NAT traversal, to build its tunnel.
Encryption and keys
Encryption scrambles data so that only someone with the right key can unscramble it. Two styles exist. With a shared key (symmetric encryption) both sides use the same secret, which is fast but requires safely sharing the secret first. With public-key (asymmetric) methods, each side has a public part anyone can see and a private part kept secret, which solves the sharing problem but is slower. Real systems, including VPNs, use public-key methods to agree on a fresh shared key, and then use that fast shared key for the bulk of the data.
Tunnels and encapsulation
A tunnel is a logical path between two points through another network. To build one, a VPN uses encapsulation: it takes a whole original data packet, encrypts it, and places it inside a new outer packet addressed between the two tunnel ends. The internet routers see only the outer packet, addressed from one VPN device to the other. They cannot see the inner addresses or the contents.
Encapsulation is like putting a letter inside a locked metal box, and then putting the box inside a courier’s envelope addressed from one branch to the other. The courier handles only the envelope. At the destination, the receiving branch opens the envelope, unlocks the box, and reads the letter.
IPsec and IKE
IPsec is the standard collection of rules for encrypting and authenticating network traffic at the IP level. Inside it, a protocol called ESP (Encapsulating Security Payload) does the actual encryption of the data. A companion protocol, IKE (Internet Key Exchange), is the negotiator: it lets two devices prove their identities, agree on algorithms, and create the shared keys. IKE runs over UDP port 500, and when a NAT device is in the path it switches to UDP port 4500. Azure VPN Gateway supports IKE version 2 for site connections, and also version 1 for some situations.
Ports and firewalls
A port is a numbered door on a device, such as 443 for secure web traffic. A firewall is a guard that decides which doors are open to which visitors. For VPNs, firewalls on the path must allow the VPN’s own traffic, such as UDP 500, UDP 4500, and ESP, or the tunnel will never form. This simple fact explains a large share of “my VPN won’t connect” problems.
When a VPN fails, ask four questions in order. Can the two ends reach each other over the internet? Do they agree on keys and settings? Do both sides know the right routes? Is any firewall or security rule blocking the inner traffic? Most problems fall into one of these four buckets.
3What Azure VPN Gateway Is
With the basics in hand, we can define the service, see its three kinds of connections, and compare it with its closest relatives.
The short definition
Azure VPN Gateway is a managed service that sends encrypted traffic between an Azure virtual network and another location over the public internet, or between Azure virtual networks over Microsoft’s backbone. “Managed” means Microsoft runs the underlying machines, patches them, and keeps two of them ready for you, so you configure behaviour instead of maintaining servers. A virtual network is your own private network in Azure, and the VPN gateway is the single locked door that leads into and out of it for tunnel traffic.
A VPN gateway is the secure customs checkpoint at the edge of a private country. Every shipment passing in or out must come through this checkpoint, where officials verify identity, open the sealed containers using the agreed keys, and send the goods on to the right town. No one can sneak in through a side path.
The three connection types
Network to network
Connects a whole on-premises network, such as an office or data centre, to an Azure virtual network through an IPsec tunnel between two VPN devices. Users on either side need no special software.
One device to the cloud
Connects an individual laptop or phone to an Azure virtual network using a client program. Ideal for remote workers and administrators.
Cloud network to cloud network
Connects two Azure virtual networks, possibly in different regions or subscriptions, using gateways on both sides.
These can be combined on the same gateway. One gateway can carry several site-to-site tunnels for branch offices, many point-to-site connections for remote staff, and a couple of VNet-to-VNet links, up to the limits of the chosen size.
Route-based and policy-based gateways
VPN gateways come in two flavours. A route-based gateway decides what goes into the tunnel by looking at its routing table, treating the tunnel like any other network link. This is flexible, supports dynamic routing with BGP, many tunnels at once, and every connection type, and it is the standard choice today. A policy-based gateway decides by fixed rules that list exactly which address ranges may use the tunnel. It is older, limited to a single tunnel and few features, and survives mainly for compatibility with some old devices. Unless a specific device forces your hand, choose route-based.
Gateway sizes
You choose a SKU, which is simply a size or edition, for the gateway. A larger SKU gives more throughput and allows more tunnels and connections. Current production SKUs are named VpnGw1 through VpnGw5, and versions with “AZ” in the name spread their instances across availability zones for extra resilience. Older sizes, including a Basic SKU, still appear in documents but are not recommended for new work because they lack important features, so check the current documentation for their status and retirement dates. Gateways also come in generations, where generation 2 offers higher performance at several sizes.
| SKU family | Typical purpose | Approximate aggregate throughput |
|---|---|---|
| VpnGw1 and VpnGw1AZ | Small offices, development, light remote access | Several hundred Mbps |
| VpnGw2 and VpnGw2AZ | Medium workloads, a handful of sites | Around 1 to 1.25 Gbps |
| VpnGw3 and VpnGw3AZ | Larger production links | Around 1.25 to 2.5 Gbps |
| VpnGw4 and VpnGw4AZ | Heavy traffic, many tunnels | Around 5 Gbps |
| VpnGw5 and VpnGw5AZ | Highest throughput and tunnel counts | Up to about 10 Gbps |
The numbers above are approximate guides. Exact throughput, tunnel counts, and connection limits differ by generation and change over time, so always read the current SKU table in Microsoft’s documentation before you size a real project. A single tunnel also has its own ceiling, much lower than the aggregate figure.
VPN Gateway versus its neighbours
People often confuse VPN Gateway with other Azure networking services. ExpressRoute is the dedicated private line mentioned earlier. VNet peering links two Azure virtual networks directly with no gateway at all, and is usually the better choice between two Azure networks. Azure Virtual WAN is a larger managed service that can host many VPN connections and spread them across a global hub. Azure Bastion offers browser-based remote access to virtual machines without a VPN. Chapter 14 compares all of these in detail.
4Architecture and Components
A VPN gateway deployment is made of a few named pieces. Learn what each one is and how they fit together, and every portal screen becomes readable.
flowchart LR ONPREM["On-premises network"] --> DEV["On-premises VPN device"] DEV --> INET["Public internet with encrypted tunnel"] INET --> PIP["Gateway public IP address"] PIP --> VGW["Azure VPN Gateway"] VGW --> GS["GatewaySubnet"] GS --> VNET["Azure virtual network and its subnets"] LNG["Local network gateway"] -.-> VGW CONN["Connection with shared key and policy"] -.-> VGW
The virtual network and the gateway subnet
Everything starts with an Azure virtual network, divided into subnets. A VPN gateway needs a special subnet that must be named exactly GatewaySubnet. Azure places the gateway’s instances in this subnet and gives each one a private address from it. The subnet is reserved for the gateway alone: you must not put virtual machines or other services in it, and you should not attach a network security group to it, since that can break the gateway. Microsoft recommends a size of /27 or larger so that there are enough addresses for growth, extra features, and coexistence with other gateway types.
The gateway subnet is the diplomatic compound inside the country: a small, fenced area reserved for the embassy staff. Ordinary citizens do not live there, and ordinary building rules do not apply, because the embassy has special duties.
The virtual network gateway
The virtual network gateway is the resource you actually create and pay for. Behind it, Azure runs at least two virtual machine instances, normally one active and one on standby, in the gateway subnet. You choose its type (VPN), its VPN type (route-based), its SKU, whether it is active-active, and whether BGP is on. Creating one is not instant: provisioning can take thirty minutes or more, which is why you should create it early in a project.
The public IP address
The gateway needs a public IP address so that the other end of a tunnel can find it on the internet. This is the address your on-premises device is configured to dial. Use the Standard type of public IP, since older types are being retired, and note that the address is tied to the gateway for its life, so plan DNS and firewall rules around it.
The local network gateway
Azure also needs a description of the other side. A local network gateway is a small resource that records the other end’s public IP address (or name) and the address ranges that live behind it. Despite its name, it is not a device. It is an entry in Azure’s address book that says “the office is at this public address and owns these private ranges.” If BGP is used, it also records the peer’s BGP address and number.
The connection
A connection ties the pieces together. It joins the virtual network gateway to a local network gateway (or to another virtual network gateway), names the connection type, and holds the pre-shared key, a secret string that both sides must know to prove they are authorised. It can also carry a custom IPsec and IKE policy, settings for BGP, and options such as connection mode.
The on-premises VPN device
On the other end, a physical or virtual VPN device, such as a firewall or router, must be configured to match. Many vendors’ devices are known to work, and Microsoft publishes configuration guidance for common ones. The device needs a public address of its own, the same pre-shared key, matching encryption settings, and the right local and remote address ranges. A mismatch in any of these prevents the tunnel from forming.
Point-to-site extras
For point-to-site connections, the gateway also holds a client address pool, a private range from which connecting laptops receive addresses, the chosen tunnel type and authentication method, and, for certificate authentication, the root certificate used to validate client certificates. Chapter 8 covers these in detail.
| Component | What it is | Plain-words job |
|---|---|---|
| Virtual network | Your private network in Azure | The destination everyone wants to reach |
| GatewaySubnet | Reserved subnet with a fixed name | The compound where the gateway lives |
| Virtual network gateway | The managed VPN service | The secure customs checkpoint |
| Public IP address | Internet-facing address | The address other ends dial |
| Local network gateway | Description of the remote site | An address-book entry for the other side |
| Connection | The link definition with the secret | The signed agreement between the two sides |
| On-premises VPN device | Your firewall or router | The matching checkpoint on your side |
Draw the picture before you click anything: the address ranges on both sides, the gateway subnet range, the public addresses, and the shared key location. Most failed first attempts come from mistakes visible on that single drawing.
5How It Works Inside: Tunnels, Keys, and the Life of a Packet
Now we look under the bonnet. How do two devices that have never met build a secure tunnel, and what happens to a single packet that crosses it?
sequenceDiagram participant D as On-premises device participant G as Azure VPN Gateway D->>G: IKE_SA_INIT with proposals and key exchange G-->>D: Chosen algorithms and key exchange reply D->>G: IKE_AUTH with identity and proof of shared key G-->>D: Authentication accepted and child SA agreed D->>G: Encrypted ESP packets with real traffic G-->>D: Encrypted ESP packets with replies D->>G: Periodic keepalive and rekey messages
Phase one: building a safe conversation channel
Before any real data flows, the two devices must talk to each other safely, even though the internet in between is hostile. In the first stage, one side proposes a list of acceptable encryption algorithms, hashing methods, and key-exchange groups. The other side picks one that it also supports. They then perform a mathematical key exchange, called Diffie-Hellman, which lets two parties create a shared secret over an open line without ever sending the secret itself. Anyone watching sees only numbers that are useless without private values never transmitted.
Imagine two people who each mix a secret paint colour into a common yellow base and swap the mixed pots in public. Each then adds their own secret colour to the pot they received. Both end up with exactly the same final colour, yet an observer who saw only the swapped pots cannot work out that colour. Diffie-Hellman is this trick done with mathematics.
Authentication: proving who you are
Agreeing on keys is not enough, since you might be talking to an impostor. In the authentication step, each side proves it knows the pre-shared key (or presents a valid certificate where supported) in a way that does not reveal the key itself. If the key on one side is different by even one character, authentication fails and the tunnel never forms. This is the most common beginner error, and the cause is almost always a typo or a hidden trailing space.
Phase two: creating the data channels
Once the first channel is safe, the devices use it to negotiate the actual child security associations, the settings and keys for the data tunnel. They agree on which address ranges are allowed through (called traffic selectors), which ESP encryption and integrity algorithms to use, and how long the keys last. Traffic then flows inside ESP packets. Keys are replaced regularly in a process called rekeying, so that even if an attacker somehow captured a key, it would only unlock a small slice of traffic.
The life of one packet
A computer sends data
An office computer at 192.168.1.20 sends a request to a cloud server at 10.1.5.4. Its local router sends it to the VPN device because the cloud range is routed that way.
The device encrypts and wraps
The VPN device encrypts the whole original packet, adds an integrity check, and wraps it in an outer packet addressed from its own public address to the gateway’s public address.
The internet carries the outer packet
Routers across the internet see only the outer addresses. The inner addresses and contents are hidden.
The Azure gateway receives and checks
The gateway verifies the integrity check, decrypts the packet, and recovers the original data with its original addresses.
The virtual network delivers
The gateway forwards the original packet into the virtual network, where normal Azure routing and security rules deliver it to 10.1.5.4.
The reply travels back
The reply follows the same path in reverse, encrypted by the gateway and decrypted by the office device.
The hidden cost of wrapping: MTU
Every network link has a maximum transmission unit (MTU), the largest packet it will carry, commonly 1,500 bytes. Wrapping and encrypting add extra bytes of header, so a packet that was exactly full-size before becomes too big afterwards. The network then has to split it into pieces, a process called fragmentation, which slows things down or, where fragments are dropped, makes connections hang. The usual remedy is to lower the maximum segment size (MSS) that TCP connections announce, so that data is cut into smaller chunks from the start. A figure around 1,350 bytes is a commonly suggested starting point, but follow your device vendor’s and Microsoft’s current advice and test.
A classic mystery symptom is a tunnel that shows as connected, small requests such as ping that work, and larger transfers that hang or crawl. That pattern points strongly to an MTU or MSS problem rather than a broken tunnel. Check packet sizes before changing keys or routes.
Keeping the tunnel alive
Tunnels are kept up by keepalive messages and dead peer detection, a mechanism where each side checks that the other still responds and rebuilds the tunnel if not. When your on-premises device is behind a NAT, the devices use UDP port 4500 and send regular small packets so the NAT does not forget the path. When a tunnel drops, either side can start negotiating a new one, and Azure’s connection status changes from Connected to Connecting or Not connected while this happens.
6Site-to-Site Connections in Depth
Site-to-site is the most common use of VPN Gateway: joining a whole office or data centre network to Azure. This chapter walks through the stages and the settings that matter.
The big picture of building one
Plan the addresses
List every address range on-premises and in Azure. Confirm that nothing overlaps. Pick a range for the gateway subnet.
Create the virtual network and GatewaySubnet
Build the network with its subnets and add the specially named gateway subnet, sized /27 or larger.
Create the gateway and its public IP
Choose route-based, a sensible SKU, zone-redundant if available, and decide on active-active and BGP. Wait for provisioning to finish.
Create the local network gateway
Record the on-premises device’s public address and the address ranges behind it.
Create the connection
Link the two, set the shared key, and choose IPsec and IKE settings.
Configure the on-premises device
Match the key, encryption settings, addresses, and routes. Allow the VPN traffic through any firewall.
Test and verify
Check that the connection shows Connected, then test real traffic in both directions, including large transfers.
Building a site-to-site link is like arranging a regular delivery between two warehouses. Both sides must agree on the street addresses, the password the drivers will say at the gate, the type of padlock on the containers, and which goods are allowed. If either side writes one detail differently, the gate stays shut.
The pre-shared key
The pre-shared key (PSK) is a secret string that must be identical on both ends. Choose a long, random value, at least thirty-two characters, with no easily guessed words. Store it in a proper secret store such as Azure Key Vault, not in a shared document or a chat message. Rotate it on a schedule and whenever someone who knew it leaves the team. Remember that changing it requires updating both ends at nearly the same time, so plan a short maintenance window.
IPsec and IKE policies
The gateway offers sensible default settings and also accepts several proposals when negotiating, which is why many devices connect without special effort. However, many organisations need exact control, for example to meet a compliance requirement or to match a device that supports only certain algorithms. For this, a custom IPsec and IKE policy lets you specify the encryption algorithm, integrity algorithm, Diffie-Hellman group, lifetimes, and perfect forward secrecy setting. When you set a custom policy, the gateway uses only that policy, so the device must match it exactly.
Perfect forward secrecy (PFS) means that each new data key is derived from a fresh key exchange, so the compromise of one key reveals nothing about past or future keys. It is the safer choice and is commonly required by security standards.
| Setting | What it controls | Practical advice |
|---|---|---|
| IKE version | Which negotiation protocol is used | Prefer IKEv2 for new connections |
| Encryption | How the data is scrambled | Use strong modern ciphers such as AES-256 or AES-GCM |
| Integrity | How tampering is detected | Use SHA-256 or stronger, avoid old hashes |
| DH group | Strength of the key exchange | Choose a modern, strong group your device supports |
| PFS group | Fresh keys for each data tunnel | Enable it unless a device forbids it |
| Lifetimes | How long keys live before rekeying | Match both sides to avoid brief drops |
| Traffic selectors | Which address ranges the tunnel carries | Route-based gateways usually allow any, with routing deciding |
Choosing the connection protocol
Connections can use IKE version 2, which is the modern choice, or IKE version 1, which exists for older devices. Check what your device supports and prefer the newest. Where your on-premises device is behind a NAT, the devices automatically use NAT traversal over UDP 4500, but not every device or NAT behaves well, so test it and confirm with the vendor.
On-premises device considerations
- Public address: use a fixed public address if you can. If your provider gives a changing address, the tunnel will break whenever it changes.
- Firewall rules: allow UDP 500, UDP 4500, and the ESP protocol between your device and the Azure gateway’s public address.
- Routes: make sure your office routers send traffic for the Azure ranges to the VPN device.
- Clock and time: keep device clocks synchronised, since some checks and logs depend on accurate time.
- Firmware: update the device. Old firmware often has known VPN bugs and security flaws.
- Supported list: look for the vendor in Microsoft’s list of validated devices, which comes with tested configuration examples.
Connection modes and who starts the tunnel
By default either side can start the tunnel, and whichever needs it first begins the negotiation. Some designs prefer that the on-premises side always initiates, for example when the Azure side must not dial out to a changing address, and the connection can be set to respond-only mode. Whichever you choose, document it, since it affects what you check first when the tunnel is down.
Always keep both sides’ configuration in files under version control. When a tunnel fails at midnight, being able to compare “what we intended” with “what is actually set” is the fastest way to the cause.
A hypothetical example
A small manufacturer connects its factory to Azure. The factory range is 192.168.10.0/24 and the Azure network is 10.20.0.0/16. The gateway subnet is 10.20.255.0/27. The local network gateway records the factory firewall’s fixed public address and the 192.168.10.0/24 range. A custom policy requires AES-256, SHA-256, a strong DH group, and PFS. The key is a random 40-character value in Key Vault. After the tunnel connects, the team tests a large file copy to confirm there is no MTU problem and then schedules a reminder to rotate the key every year.
7Routing: Static, BGP, Hub and Spoke, and Forced Tunneling
A tunnel that is up but has no route is like a road with no signposts. Routing decides who can reach whom, and getting it right is as important as the tunnel itself.
Static routing: write the map by hand
With static routing, you list the address ranges that live behind each side. In Azure, the local network gateway holds the on-premises ranges, and the gateway automatically adds routes for them. On-premises, you configure the device to send the Azure ranges into the tunnel. Static routing is simple and predictable, and it suits small, stable networks. Its weakness is that every change, such as a new subnet at the office, requires someone to edit the list on at least one side, and forgetting means that the new subnet cannot be reached.
BGP: let the networks talk
With BGP, the two sides advertise their address ranges to each other automatically. When a new subnet appears, it is learned within seconds. If one tunnel fails, routes through it are withdrawn and traffic uses another path. Each network has an autonomous system number (ASN), an identifier for its routing domain. Azure VPN gateways use the default private ASN 65515, and you can choose another if it clashes with your own. You give each side a BGP peer address, and the gateway shows learned and advertised routes so you can verify them.
Static routes are a printed railway timetable pinned to a wall. BGP is the live departure board: whenever a train is cancelled or a new service starts, the board updates by itself, and every passenger sees the change immediately.
| Question | Static routing | BGP |
|---|---|---|
| Setup effort | Low at first | Moderate |
| Handles changes | Manually | Automatically |
| Multiple tunnels and failover | Limited and awkward | Natural and fast |
| Transit between sites | Hard | Possible with care |
| Best for | One small site, stable ranges | Multiple sites, redundancy, growth |
System routes and user-defined routes
Inside the Azure virtual network, traffic follows system routes that Azure creates automatically, including routes learned from the gateway. You can override them with a route table containing user-defined routes (UDRs), for example to force traffic through a firewall appliance. Take care: applying a route table to the gateway subnet is risky and, in many cases, unsupported, because the gateway needs to manage its own routes. Apply route tables to the workload subnets instead.
Hub and spoke with gateway transit
Larger organisations often arrange their Azure networks in a hub and spoke pattern. One central hub virtual network holds shared services, including the VPN gateway. Several spoke networks hold the individual applications, and each spoke is joined to the hub by VNet peering. With a feature called gateway transit, the spokes can share the hub’s VPN gateway instead of each needing its own, which saves money and keeps connectivity in one place.
flowchart LR OFFICE["Office network"] --> TUN["VPN tunnel"] TUN --> HUBGW["VPN Gateway in hub network"] HUBGW --> HUB["Hub virtual network with shared services"] HUB --> SP1["Spoke 1: web application"] HUB --> SP2["Spoke 2: data platform"] HUB --> SP3["Spoke 3: test environment"] REMOTE["Remote laptops"] --> HUBGW
To make this work, the peering on the hub side allows gateway transit, and the peering on each spoke side is set to use the remote gateway. After any change in the gateway or peering, spokes may need their peering refreshed, or new routes may not appear. Spokes do not automatically reach each other through the hub unless you add routing for that, usually through a firewall in the hub, because peering is not transitive by default.
Forced tunneling
Some organisations require that all internet-bound traffic from Azure workloads travel back through the company’s on-premises firewall for inspection. This is called forced tunneling. It is done by advertising a default route, meaning “everything else,” toward the tunnel. It satisfies strict policies, but it makes cloud servers’ internet access depend on the VPN link and on-premises device, adds delay, and can break services that must reach Azure platform addresses directly. Use it only when required, and test thoroughly.
Forced tunneling, or any default route pointing at a firewall, can accidentally cut off traffic that Azure itself needs, such as management and activation traffic for virtual machines. Plan exceptions and test with a single non-critical machine before applying it widely.
Overlapping address ranges and NAT
When two networks overlap and you cannot renumber either, the VPN gateway offers a NAT feature that translates one range to a different, non-overlapping range as traffic crosses the tunnel. It is useful after mergers or when connecting partners who use common ranges. It adds complexity, so treat it as a repair, not a design goal, and read the current documentation for supported scenarios and limits.
8Point-to-Site: Connecting Individual Devices
Not every connection is an office. Often it is a person with a laptop. Point-to-site gives each device its own secure tunnel into your Azure network.
How it works
A user starts a VPN client program on a laptop. The client contacts the gateway’s public address, proves who the user is, and the gateway gives the laptop an address from a private client address pool you defined. The laptop is then effectively part of the Azure network and can reach the resources the routes and rules allow. When the user disconnects, the address returns to the pool. No hardware at the user’s location is needed, which is why the model is popular for remote work.
Site-to-site is a permanent tunnel between two buildings. Point-to-site is a visitor badge: each person arriving at the front desk proves who they are, receives a temporary badge, and can walk only through the doors that the badge opens until they leave.
Tunnel types
Flexible and firewall friendly
An SSL-based protocol that uses TCP port 443, which is usually open even on restrictive networks. Works on Windows, macOS, Linux, iOS, and Android. The only type that supports Microsoft Entra ID sign-in.
Standards based
An IPsec-based protocol using UDP 500 and 4500. Built into many operating systems, which is convenient, but some networks block those ports.
Windows only
A protocol over TCP 443 supported only on Windows and limited in the number of simultaneous connections. Mostly used for older setups.
You can enable several types on one gateway so that different devices use what works for them. The practical advice is to start with OpenVPN for the widest compatibility, and add others only where there is a reason.
Authentication methods
- Microsoft Entra ID: users sign in with their normal work account, and your organisation can apply multifactor authentication and conditional access, rules such as “only from managed devices.” This is the strongest and most manageable option and works with OpenVPN and the Azure VPN Client.
- Azure certificate: you upload a root certificate to the gateway, and each user’s device carries a client certificate issued from it. Secure if you manage certificates well, but distribution and revocation take effort.
- RADIUS: the gateway asks an existing authentication server, such as one used for other company services, to approve each login. Useful where such a server already exists.
Split tunnelling and what traffic goes where
By default, a point-to-site client sends only traffic destined for Azure ranges into the tunnel, and everything else goes straight to the internet. This is called split tunnelling, and it keeps the gateway free of video calls and web browsing. If policy requires all traffic to go through the tunnel, a default route can be pushed to clients, at the cost of more load and delay. Remember that when the Azure network’s ranges change, clients may need to download an updated profile to learn the new routes.
Client software and profiles
Microsoft provides the Azure VPN Client for several platforms, and standard OpenVPN clients can also be used with exported profiles. Administrators distribute a configuration profile to each user, often through device management tools. When you change the gateway’s authentication or address settings, you may need to regenerate and re-issue profiles, so plan the rollout.
| Need | Recommended choice | Reason |
|---|---|---|
| Staff on mixed laptops and phones | OpenVPN with Entra ID | Works everywhere, supports MFA |
| Strict hotel and café networks | OpenVPN on TCP 443 | Port 443 is rarely blocked |
| Existing RADIUS infrastructure | RADIUS authentication | Reuses current accounts and policies |
| Managed devices with certificates | Certificate authentication | Good for device-level trust |
| Hundreds or thousands of users | Check gateway SKU limits, consider Virtual WAN | Connection counts differ by SKU |
Each SKU supports a maximum number of simultaneous point-to-site connections, and some tunnel types have lower limits than others. Always check the current limits for your chosen SKU and consider expected peak numbers, such as everyone connecting at nine o’clock on a Monday morning.
Good habits for remote access
- Use Entra ID with multifactor authentication and conditional access wherever you can.
- Give users access only to what they need, using network security groups and routing, not the whole network.
- Keep the client address pool separate from every other range, and large enough for peak users.
- Disable access promptly when someone leaves, and review active users regularly.
- Log connections, so you can see who connected, when, and from where.
9VNet-to-VNet and Connecting Azure Networks
Sometimes both ends of the connection are in Azure. There are two ways to join them, and choosing the right one saves money and effort.
VNet-to-VNet over VPN
A VNet-to-VNet connection uses a VPN gateway in each of the two virtual networks and an encrypted tunnel between them, much like a site-to-site connection. The networks can be in different regions, different subscriptions, or even different Microsoft Entra tenants. Traffic travels over Microsoft’s backbone network, not the public internet, though it is still encrypted by IPsec.
VNet peering: the simpler cousin
VNet peering joins two virtual networks directly through Microsoft’s backbone, with no gateway and no encryption layer of its own. It is faster, has lower delay, costs less, and has no gateway bandwidth limits. It is the preferred way to connect two Azure virtual networks in the great majority of cases. The main reasons to choose a VPN gateway between networks instead are a requirement for IPsec encryption on the link by policy, a need to connect across boundaries that peering does not support, or the use of existing gateway-based routing designs.
Peering is like opening a door in the wall between two adjoining offices in the same building: quick, private, and free of ceremony. A VNet-to-VNet VPN is like sending a sealed armoured van between two offices, even though both sit within the same secure campus. It is sometimes required by policy, but if you do not need the armour, the door is faster.
| Question | VNet peering | VNet-to-VNet VPN |
|---|---|---|
| Needs gateways | No | Yes, one per network |
| Extra encryption | No, relies on Microsoft backbone | Yes, IPsec |
| Throughput limit | No gateway limit | Limited by gateway SKU |
| Delay | Lowest | Slightly higher |
| Cost | Lower, charged per data transferred | Gateway hourly cost plus data |
| Setup effort | Low | Moderate, with gateway provisioning time |
| Typical use | Most Azure-to-Azure links | Policy-driven encryption or special cases |
Combining VPN and peering
The two are not enemies. A very common design uses peering between hub and spokes inside Azure, and a VPN gateway in the hub for the connections to offices and remote users, as shown in chapter 7. Gateway transit is what makes the two features cooperate.
Cross-region and cross-subscription planning
When networks sit in different regions, remember that distance adds delay, which cannot be removed: light in fibre travels roughly 200,000 kilometres per second, so a path of 1,000 kilometres adds about five milliseconds each way. Data crossing regions can also cost more than data staying inside one region. When networks sit in different subscriptions, make sure the right people have permissions to create the links on both sides, and agree who owns shared keys and who responds to problems.
Before you reach for a VNet-to-VNet VPN, ask: “Which requirement does this meet that peering does not?” If the honest answer is “none,” use peering and save yourself the gateway cost and the bandwidth ceiling.
10Resilience: Surviving Failures
A single tunnel on a single device is a single point of failure. Production designs plan for broken devices, broken links, and broken data centres.
Where things can fail
A VPN connection has many parts, and any of them can fail. The Azure gateway instance can be restarted for maintenance. The on-premises device can crash or be rebooted. The office’s internet link can be cut by a digger. An internet provider can have a routing fault. A whole Azure data centre can lose power. The aim of resilience design is that a failure of any one of these causes a brief hiccup, not an outage.
Active-standby: the default
By default, a gateway runs two instances: one active carrying traffic and one standby ready to take over. If the active instance fails, or Azure performs planned maintenance, the standby takes over within a short time, typically seconds to a minute or so, and tunnels reconnect. This protects against Azure-side failures but not against a failure on your own device, and tunnels do drop briefly during switchover.
Active-active: both instances working
In active-active mode, both gateway instances have their own public IP address, and each can hold tunnels at the same time. Your on-premises device can connect to both, so if one instance is restarted, the other keeps carrying traffic without waiting for a switchover. Combined with BGP, traffic can use both tunnels, and the failure of one simply shifts the traffic to the other.
flowchart LR DEVA["On-premises device A"] --> T1["Tunnel 1"] DEVA --> T2["Tunnel 2"] DEVB["On-premises device B"] --> T3["Tunnel 3"] DEVB --> T4["Tunnel 4"] T1 --> GW1["Gateway instance 1"] T3 --> GW1 T2 --> GW2["Gateway instance 2"] T4 --> GW2 GW1 --> VNET["Azure virtual network"] GW2 --> VNET
Active-standby is a bridge with one open lane and a second lane closed, ready to open when the first is blocked. Active-active is a bridge with two open lanes, so that closing one just means traffic squeezes into the other.
Zone redundancy
A VPN gateway SKU with “AZ” in its name spreads its instances across availability zones, physically separate data centre buildings within a region, each with independent power and cooling. A zone-redundant gateway survives the loss of an entire zone. For new production deployments, zone-redundant SKUs are the default choice wherever the region supports them, and the extra cost is modest compared with the protection.
Redundancy on your own side
Even the best Azure design fails if your office has a single device and a single internet line. A full design has two VPN devices at the office, possibly through two different internet providers, each connected to the gateway. With an active-active gateway and two devices, you get four tunnels, as shown in the figure. BGP lets the networks reroute automatically if any tunnel fails.
Backing up a private line with a VPN
A common pattern combines ExpressRoute, the dedicated private circuit, with a VPN as the backup. Both can be attached to the same virtual network, and the routing is arranged so that the ExpressRoute path is preferred and the VPN takes over if ExpressRoute fails. This coexistence gives the speed and reliability of a private line with the lower cost and quick setup of a VPN as insurance. It needs careful routing design, so test the failover on purpose before you need it.
Testing failure on purpose
- Reboot one gateway instance during a maintenance window and watch tunnels and application behaviour.
- Disable one on-premises device or tunnel and confirm that traffic moves to the other path.
- Measure how long the switchover takes, and compare it with your applications’ timeouts.
- Write down the results, and repeat the test after any big configuration change.
| Design | Survives Azure instance failure | Survives device failure | Survives zone loss |
|---|---|---|---|
| Single tunnel, active-standby, non-zonal | With a brief drop | No | No |
| Active-standby, zone-redundant SKU | With a brief drop | No | Yes |
| Active-active, one device | Yes, quickly | No | Depends on SKU |
| Active-active, two devices, BGP, zone-redundant | Yes | Yes | Yes |
11Performance and Scalability
A VPN that is secure but painfully slow will be abandoned by its users. This chapter explains what limits VPN speed and how to estimate and improve it.
Five limits in a chain
The speed of a VPN link is set by the slowest of several things. The first is the internet connection at each end: a 200 Mbps office line cannot carry a 1 Gbps tunnel. The second is the gateway SKU, which has an aggregate throughput limit. The third is the single tunnel limit, because one tunnel and especially one encrypted flow can carry less than the whole gateway. The fourth is the on-premises device, whose processor must encrypt and decrypt every packet. The fifth is latency, the delay between the two ends, which limits how fast a single connection can ramp up.
Imagine a water pipeline made of different sections: a wide main, a narrow valve, a medium hose, and a small tap at the end. The flow you get is set by the narrowest part. Buying a wider main does nothing if the valve is the bottleneck, so you must find the valve.
Latency and the single-connection limit
Latency is the delay for data to travel from one end to the other and back, called the round-trip time. A single TCP connection can only have a limited amount of unconfirmed data in flight, called its window. If the window is 64 kilobytes and the round-trip time is 20 milliseconds, then at most 64 kilobytes can be delivered every 20 milliseconds, which is about 26 megabits per second, no matter how fast the pipe is. Modern systems scale the window, but the lesson holds: a single file copy over a long-distance VPN may be far slower than the link’s rating, while many parallel connections together can fill the pipe.
Estimating transfer times
As with any link, estimate before you start. Data sizes are in bytes, but link speeds are in bits, and there are eight bits to a byte. A 2 terabyte transfer is about 16,000 gigabits. At a steady 500 megabits per second, that is 32,000 seconds, or about 8.9 hours. Real transfers rarely reach the rated speed, because of encryption overhead, packet headers, and competing traffic, so assume about 70 percent, which makes it close to 12.7 hours.
| Effective speed | Time for 1 TB | Time for 10 TB |
|---|---|---|
| 100 Mbps | About 22 hours | About 9 days |
| 500 Mbps | About 4.4 hours | About 1.9 days |
| 1 Gbps | About 2.2 hours | About 22 hours |
| 5 Gbps | About 27 minutes | About 4.4 hours |
If a large one-time bulk copy would take weeks, a VPN is the wrong tool for that job. Use a shipped offline device or a dedicated circuit for the bulk load, and keep the VPN for everyday traffic and small changes.
Choosing a gateway size
Start by listing your needs: the peak aggregate traffic across all tunnels, the number of site-to-site tunnels, the number of simultaneous point-to-site users, whether BGP is needed, and whether zone redundancy is required. Pick a SKU whose published limits are comfortably above those needs, with headroom of at least thirty percent, since a gateway running close to its limit adds delay and drops packets. You can resize a gateway within the same family without rebuilding it in many cases, but changes between certain generations or types may require recreation, so check the current documentation before relying on it.
Ways to improve throughput
- Use multiple tunnels and active-active so that traffic spreads across several paths, and use BGP to balance it.
- Tune MSS and MTU so that packets are not fragmented.
- Choose faster encryption modes such as AES-GCM, which processes encryption and integrity together and is often faster on modern hardware.
- Upgrade the on-premises device if its processor is the limit, or enable hardware encryption support.
- Use parallel transfers for bulk data so that many connections share the pipe.
- Put workloads close to users, in the nearest suitable region, to cut latency.
- Move to ExpressRoute when you need predictable, high bandwidth, and low delay beyond what internet VPNs deliver.
Do not judge a VPN by a speed test from one laptop to one server. A single flow is limited by latency and window size. Test with several parallel flows and with realistic application traffic before concluding that the gateway is too small.
Scaling out beyond one gateway
When a single gateway reaches its limit, you have options. You can move to a larger SKU. You can add additional gateways in other virtual networks and split sites among them. For many branches across a wide area, Azure Virtual WAN provides a managed hub-based service built to scale to many sites, which chapter 14 describes. Plan for growth early, because redesigning connectivity after hundreds of sites are live is painful.
12Security: Keeping the Tunnel and Its Contents Safe
A VPN exists to provide security, but a poorly run VPN can create new risks. This chapter shows how to make the tunnel itself strong and how to limit what a tunnel can reach.
Strong cryptography
Choose modern algorithms and avoid outdated ones. For encryption, AES with 256-bit keys or AES-GCM is the standard choice. For integrity, SHA-256 or stronger. Choose strong Diffie-Hellman groups and enable perfect forward secrecy. Avoid old protocols and algorithms with known weaknesses, even if a device offers them as defaults. Where compliance rules define allowed algorithms, apply a custom IPsec and IKE policy that enforces them, and review it whenever standards change.
Protect the secrets
- Pre-shared keys: long, random, unique per connection, stored in Key Vault, and rotated on a schedule.
- Certificates: for point-to-site, protect the root certificate’s private key carefully, and revoke client certificates promptly when a device is lost.
- Configuration files: remove keys before sharing a configuration or putting it in a ticket or repository.
- Administrator access: limit who can read or change gateway and connection settings, using role-based access control.
A strong tunnel with a weak key is like an armoured van whose door key is taped under the bumper. The van’s strength means nothing if anyone can find the key. Guarding the keys is half the job.
Authenticate people properly
For point-to-site access, use Microsoft Entra ID with multifactor authentication and conditional access so that a stolen password alone does not open the door. Conditional access can require a compliant, managed device, a trusted location, or low sign-in risk. Where certificates are used, issue them only to managed devices. Make sure leaving employees lose access on the day they leave.
A tunnel is not a free pass
A common and dangerous belief is that anything arriving through the VPN is trusted. This is false. A laptop that connects might be infected. An office network might contain a compromised machine. Treat traffic from the tunnel as untrusted until checked, the idea behind zero trust. Apply controls inside the Azure network as well:
- Network security groups (NSGs) on workload subnets, allowing only the specific ports and sources needed from the VPN ranges.
- Azure Firewall or a similar inspection service in the hub, to filter, log, and inspect traffic between the VPN ranges and workloads.
- Segmentation: give remote users access to only the subnets they need, not everything.
- Private endpoints for platform services, so that databases and storage are reachable only through private addresses.
- Just-in-time and least-privilege administration, so that even a connected user cannot reach management ports without approval.
Protect the gateway’s front door
The gateway’s public IP address is visible on the internet and will be probed. Only the VPN protocols are listening, which keeps the exposed surface small. Enable Azure DDoS Protection on the virtual network if the gateway is a critical entry point, since a flood of junk traffic at the gateway can disrupt every tunnel. On the on-premises side, restrict who can reach the VPN device’s management interface, and keep its software updated.
Log and watch
Turn on diagnostic logs for the gateway, and send them to a central workspace. Alert on tunnel disconnects, repeated failed authentications, unusual connection volumes, and logins from unexpected places. Logs are also your evidence in an audit or incident, so choose a retention period that matches your obligations.
| Risk | Control |
|---|---|
| Eavesdropping on traffic | Strong IPsec policy with perfect forward secrecy |
| Stolen or leaked shared key | Long random keys in Key Vault, rotation, minimal sharing |
| Stolen user password | Entra ID with MFA and conditional access |
| Compromised connected device | Segmentation, NSGs, firewall inspection, least privilege |
| Flooding the gateway | DDoS protection, redundancy, monitoring |
| Unnoticed misuse | Diagnostic logs, alerts, regular access review |
Run a short yearly review of your VPN: who has access, which keys are older than your policy allows, which algorithms are in use, and which tunnels nobody uses any more. Removing unused tunnels is one of the cheapest security improvements available.
13Network Design: Addresses, DNS, and Private Services
Good VPN design is mostly good network design. Planning addresses and names before you build prevents most pain later.
Plan the address space like a city map
Give every office, data centre, Azure network, and remote user pool its own non-overlapping range, and leave room to grow. A neat approach is to reserve a large block per region or business unit and carve sub-ranges from it. Keep a single, shared record of allocations, such as a simple spreadsheet or an IP address management tool, so that no team accidentally reuses a range. Include the ranges used by point-to-site clients and by Kubernetes clusters, which can consume surprisingly large blocks.
| Network | Example range | Notes |
|---|---|---|
| Head office | 10.10.0.0/16 | Reserved block for all office subnets |
| Branch offices | 10.20.0.0/16 | A /24 per branch, up to 256 branches |
| Azure hub network | 10.30.0.0/20 | Shared services and gateway subnet |
| Azure spokes | 10.40.0.0/14 | Application networks, one /20 each |
| Point-to-site client pool | 10.90.0.0/22 | Sized for peak simultaneous users |
Planning addresses is like planning house numbers for a growing city. If every neighbourhood picks numbers on its own, two streets will end up with the same address, and the post office will be in despair. A single master map avoids that.
DNS: names, not just numbers
People and programs prefer names to numbers. DNS turns names such as sql.contoso.internal into addresses. In a hybrid setup, names must resolve correctly on both sides: an office computer must resolve the names of Azure servers, and Azure servers must resolve the names of office servers. This often requires DNS forwarding: office DNS servers forward Azure-related questions to Azure, and Azure forwards office-related questions back. Azure offers Azure DNS Private Resolver, a managed service for this, so you do not need to run your own DNS servers in virtual machines.
Private endpoints add a wrinkle. When a storage account or database gets a private endpoint, its name should resolve to a private address in your network. For on-premises users reaching it over the VPN, the office DNS must forward that name to Azure’s private DNS, or users will receive the public address and bypass the private path. Many mysterious “it works from Azure but not from the office” problems are DNS problems in disguise.
Reaching private services over the tunnel
One of the best uses of a VPN is reaching Azure services privately. With a private endpoint, an Azure service such as a storage account gets an address inside your virtual network, and on-premises computers reach it through the tunnel without any public exposure. Combine this with firewall settings on the service that deny public access. The result is a service that exists only on your private network.
Azure Virtual WAN as a design alternative
Azure Virtual WAN is a managed networking service that bundles VPN gateways, ExpressRoute gateways, and routing into a virtual hub. Instead of building and maintaining many gateways and routes yourself, you attach branches and virtual networks to the hub, and Azure handles much of the routing automatically, even between branches. It suits organisations with many sites, and its pricing and limits differ from standalone gateways. For a handful of sites, a normal VPN gateway is simpler and often cheaper; for dozens or hundreds, Virtual WAN is worth evaluating.
Network security groups and the gateway
Do not attach a network security group to the GatewaySubnet. Control access at the workload subnets that traffic reaches after the gateway. For traffic coming from the VPN, remember that source addresses will be the on-premises ranges or the point-to-site pool, so write your rules in those terms. Use service tags and application security groups to keep rules readable as the environment grows.
Common design mistakes
- Choosing a gateway subnet too small, then being unable to add features or a second gateway type.
- Picking a popular default range such as 10.0.0.0/16 or 192.168.1.0/24, which collides with a partner or a home network.
- Forgetting DNS entirely, and then connecting by IP address in a panic.
- Giving every spoke its own gateway when one shared hub gateway would do.
- Leaving the point-to-site pool too small for peak users.
14Choosing Among Azure’s Connectivity Options
Azure offers several ways to connect networks and people. Picking the right one is a design decision, and each option has a natural home.
flowchart TD
A["Need to connect to Azure"] --> B{"Who is connecting"}
B -->|"Two Azure networks"| C["VNet peering"]
B -->|"An office or data centre"| D{"Need dedicated private bandwidth"}
B -->|"Individual remote users"| E["Point-to-site VPN"]
B -->|"Admin to a few VMs only"| F["Azure Bastion"]
D -->|"Yes, high or predictable"| G["ExpressRoute"]
D -->|"No, internet is fine"| H{"How many sites"}
H -->|"A few"| I["Site-to-site VPN Gateway"]
H -->|"Dozens or more"| J["Azure Virtual WAN"]
The main options
VPN Gateway
Encrypted tunnels over the public internet. Quick and inexpensive to set up, flexible, and good for offices, remote users, and backup paths. Bandwidth and delay depend on the internet.
ExpressRoute
A dedicated connection from a provider that does not cross the public internet. Higher bandwidth, more predictable delay, and generally higher cost and lead time.
Virtual WAN
A managed service that combines many VPN and ExpressRoute connections with automatic routing. Best for many sites or global designs.
VNet peering
Direct, fast, private connection between virtual networks. No gateway needed. The default for linking Azure networks.
Azure Bastion
Browser-based remote desktop and shell access to virtual machines without public addresses or a VPN client. Good for administrators who need occasional access.
Private Link
Gives Azure services a private address in your network, reachable over VPN or ExpressRoute. A building block, not a connection by itself.
| Question | VPN Gateway | ExpressRoute | Virtual WAN |
|---|---|---|---|
| Path | Public internet, encrypted | Private provider circuit | Either, managed centrally |
| Speed to set up | Hours to days | Weeks, depends on provider | Days, once the hub exists |
| Bandwidth | Up to the gateway SKU limit, internet dependent | High and predictable | Scales with hub units |
| Delay and consistency | Variable | Stable and low | Depends on the connection type |
| Cost | Lower | Higher | Pay for hub and units |
| Encrypted by default | Yes, IPsec | No, add encryption if required | Yes for VPN parts |
| Best for | Small and medium needs, backup, remote users | Large data flows, strict performance needs | Many sites, global networks |
Combining options
These tools are layers, not rivals. A typical enterprise uses ExpressRoute for its main data centre links, VPN Gateway site-to-site tunnels as a backup and for small branches, point-to-site for remote workers, peering inside Azure, Private Link for services, and Bastion for occasional administration. Each does what it does best.
Think of different ways to travel between two cities. ExpressRoute is a private express train: reliable and fast, but expensive and slow to arrange. A VPN is a car on the public highway with a locked boot: cheap and available now, but subject to traffic. Virtual WAN is a managed bus network connecting many cities. Peering is a lift between floors of the same building.
Third-party appliances
Some organisations already run network appliances from other vendors, such as firewalls or software-defined WAN devices, and place them in Azure as virtual machines. These can act as VPN endpoints too, offering vendor-specific features and consistent management with on-premises equipment. The trade-off is that you manage the appliance, its updates, and its resilience yourself, while the managed gateway is run by Azure. Choose appliances when you need a specific feature the managed gateway does not offer.
15Monitoring and Logging
You cannot fix what you cannot see. Good monitoring tells you a tunnel is struggling before users complain.
What to watch: metrics
Azure Monitor collects numerical metrics about the gateway and its connections. The most useful ones are the following.
Tunnel state and connection status
Whether each tunnel is connected, connecting, or down. The first thing to check in any incident.
Bytes in and out, bandwidth
How much data crosses each tunnel and the gateway as a whole. Shows trends and nearness to SKU limits.
Packet drops
Counts of packets dropped, for example because of a mismatch in traffic selectors or overload. Rising numbers signal trouble.
Peer status and learned routes
Whether BGP sessions are up and how many routes were learned and advertised. A sudden change shows route trouble.
Point-to-site connection count
The number of connected clients and its peaks compared with SKU limits.
Gateway bandwidth use
Overall use against the throughput of your SKU. Sustained high values mean it is time to resize.
What happened: logs
Azure also offers diagnostic logs, which record events as text. Several log categories exist, covering general gateway events, tunnel state changes, route changes, IKE negotiation messages, and point-to-site user connections. The IKE logs are especially valuable, because they show which settings each side proposed and where negotiation failed, such as “no proposal chosen,” which means the two sides share no common algorithm. Send these logs to a Log Analytics workspace so you can search them, keep them for a suitable period, and build alerts on them.
Metrics are the dashboard dials in a car: speed, fuel, and temperature, telling you how things are now. Logs are the black box recorder: a record of what happened and in what order, which is what you need after something goes wrong.
Alerts worth setting
- A tunnel is down or flapping, meaning it repeatedly goes up and down, for more than a few minutes.
- A BGP session is down, or the number of learned routes changes sharply.
- Gateway bandwidth stays above about seventy percent of the SKU limit.
- Packet drops rise above a normal baseline.
- Point-to-site connections approach the SKU maximum.
- Gateway or connection configuration changes, from the activity log, so that you know who changed what.
Network Watcher tools
Azure Network Watcher includes tools useful for VPN work. A VPN troubleshoot check inspects a gateway or connection and reports problems it can detect. Connection troubleshooting tests reachability between a virtual machine and a destination. Next hop and effective route views show where Azure thinks traffic will go. Packet capture on gateways lets you record traffic when you need to see exactly what is crossing the tunnel, at the price of added effort and storage.
Create one dashboard showing tunnel status, bandwidth, and BGP state for every connection, and share it with your helpdesk. When someone reports “the VPN is down,” a single glance can tell you whether it truly is, and where.
Do not forget the other end
The on-premises device has its own logs and counters, often more detailed than Azure’s about why a negotiation failed. Make sure the people who manage it can share them, and set up alerting there too. When both ends log to a central place, you can follow one conversation from both sides.
16Troubleshooting: Finding the Fault Fast
VPN problems feel mysterious until you learn that they fall into a few families. Work through the layers in order and most faults surrender quickly.
A layered method
Is the tunnel up?
Check connection status in Azure and on the device. If it is not connected, the problem is in the negotiation. If it is connected, the problem is probably in routes, rules, or packet size.
Can the ends reach each other?
Confirm the on-premises device has internet access and that firewalls allow UDP 500, UDP 4500, and ESP to the gateway’s public address, and that the public address configured matches.
Do the settings match?
Compare the pre-shared key, IKE version, encryption, integrity, DH group, PFS, and lifetimes on both sides. Read the IKE logs for the exact mismatch.
Do both sides know the routes?
Check learned and advertised routes, the local network gateway ranges, and effective routes on the Azure machines and on-premises routers.
Are security rules allowing it?
Check NSGs, Azure Firewall, host firewalls, and on-premises firewall rules for the specific ports and addresses.
Do names and packet sizes work?
Test DNS resolution of the target names, and test large transfers to detect MTU problems.
Common symptoms and likely causes
| Symptom | Likely cause | What to check first |
|---|---|---|
| Tunnel never connects | Wrong shared key, mismatched policy, blocked ports, wrong peer address | IKE logs, key on both ends, firewall rules for UDP 500 and 4500 |
| Connects, then drops every few hours | Lifetime mismatch or dead peer detection differences | Rekey lifetimes and DPD settings on both sides |
| Connected, but no traffic | Missing routes, wrong local network gateway ranges, security rules | Effective routes, learned routes, NSG and firewall logs |
| Ping works, large transfers hang | MTU or MSS problem | Lower MSS on the device, test with different packet sizes |
| Works one way only | Asymmetric routing or one-sided firewall rule | Return routes and stateful firewall paths |
| Cannot reach servers by name | DNS forwarding missing | Resolver configuration and private DNS zone links |
| Point-to-site user cannot connect | Certificate, authentication, or blocked port issue | User account status, client profile age, firewall allowing TCP 443 or UDP 500 and 4500 |
| Point-to-site user connects but sees nothing | Client routes outdated or no rule for the pool | Download a fresh profile, check NSG rules for the client pool range |
| Slow speeds | Latency, single flow, small SKU, device CPU | Gateway bandwidth metric, parallel transfers, device load |
| BGP session will not come up | Wrong ASN or peer address, routes to the peer missing | BGP settings both sides, reachability of peer address through the tunnel |
The classic top five
- The pre-shared key differs by a character. Re-enter it on both sides by copy and paste, and watch out for spaces.
- Overlapping address ranges. Draw both ranges. If they overlap, the fix is renumbering or NAT.
- A firewall blocks the VPN’s own ports. Allow UDP 500, UDP 4500, and ESP.
- A policy mismatch. One side insists on an algorithm or group the other does not support.
- MTU trouble. The tunnel is fine, but big packets disappear.
Change one thing at a time and record it. Changing the key, the policy, and the routes in one burst might fix the problem, but you will never know which change did it, and you may have introduced a new problem along the way.
Resetting and recovery tools
Azure allows you to reset a connection, which forces the tunnel to renegotiate, and to reset the gateway, which restarts its instances. Both cause a brief outage, so use them with care and outside peak hours. Resetting a connection is a gentle first move for a tunnel stuck in a strange state. Resetting the whole gateway is a bigger step for when metrics and logs suggest the gateway itself is unhealthy. Always record what you did and why.
Keep a one-page run book: where the logs are, which dashboards to open, how to reset a connection, who owns the on-premises device, and how to contact the internet provider. During an outage, a clear page is worth more than a genius who cannot be reached.
17Deployment and Operations: From First Design to Daily Care
A VPN is not set up once and forgotten. Keys age, devices are replaced, offices open and close, and standards move on. Treating the VPN as a living service keeps it dependable.
flowchart LR A["Plan addresses and design"] --> B["Build as code"] B --> C["Test in a lab or staging"] C --> D["Connect production"] D --> E["Monitor and review"] E --> F["Change safely"] F --> C E --> G["Rotate keys and retire old tunnels"]
Plan and document first
Write a short design document before you create anything. It should list all address ranges, the gateway SKU and why you chose it, whether active-active, zone redundancy, and BGP are used, which authentication methods apply, who owns each on-premises device, which keys exist and where they are stored, and how failover is expected to behave. This is the page everybody will reach for during the first incident, and it is far easier to write on a calm day.
Build as code
Infrastructure as code means describing your resources in text files that a tool turns into real resources, using Bicep, ARM templates, or Terraform. A VPN deployment has many linked parts, and code makes it repeatable, reviewable, and recoverable. If a region is lost or a mistake deletes a connection, you can rebuild it from code in minutes, apart from the long gateway provisioning time. Keep secrets such as pre-shared keys out of the code itself: reference them from Key Vault at deployment time.
Building from code is like using an architect’s drawings rather than a builder’s memory. Any competent crew can rebuild the structure from the drawings, a second inspector can read them for mistakes, and the old versions show how the design changed.
Test before production
Create a lab connection that mirrors the real design, even with a smaller SKU. Many vendors’ devices have a virtual edition that can run in Azure for testing. Confirm negotiation, routes, BGP, DNS, and large transfers. Test failover by switching off a tunnel and a device. Record how long traffic takes to recover. Apply the same checks to every change before it touches production.
Change safely
Changes to a VPN affect every user of the tunnel, so schedule them in agreed windows and have a way back. Typical risky changes include changing the IPsec policy, replacing a device, changing the pre-shared key, and altering routes. For each, prepare the new configuration on both sides, apply it in a planned order, test immediately, and keep the old configuration at hand to restore if needed. Tell users in advance, since a brief drop can interrupt long file transfers or remote sessions.
Routine chores
- Key rotation: change pre-shared keys on a schedule and when staff change.
- Firmware and updates: keep on-premises devices patched, and read Azure service health notices about gateway maintenance.
- Capacity review: compare peak bandwidth and connection counts against SKU limits each quarter.
- Access review: confirm that remote users and administrators still need their access.
- Failover test: practise it at least yearly.
- Cleanup: remove unused tunnels, old local network gateways, and unused public IP addresses.
- Documentation: update the design note and run book after each change.
Moving off older gateway types
Older gateway SKUs, including the Basic SKU and non-zone-redundant sizes, are being phased out in favour of newer ones, and public IP types are changing as well. Check Microsoft’s current announcements for dates and migration tools. In many cases the safe path is to build a new gateway of the target type beside the old one, connect the same sites to both for a test period, and then switch over with a planned cutover and a rollback plan. Start early, because gateway creation takes time and your on-premises teams need to coordinate.
Put a recurring calendar item on the team’s shared calendar for key rotation, failover testing, and the yearly review. Without a visible reminder, these jobs quietly slide until an incident forces them.
18Design Patterns and Anti-patterns
A design pattern is a proven answer to a recurring problem. An anti-pattern is a tempting approach that keeps causing trouble. Here are the most useful of each for VPN designs.
Patterns worth adopting
Hub and spoke with shared gateway
One gateway in a hub, shared by all spokes through gateway transit. Simple to manage and cost effective.
Active-active with BGP
Two gateway instances, two tunnels per device, dynamic routing. Failures reroute in seconds without manual work.
Dual devices, dual providers
Two on-premises devices on two internet lines so no single local failure breaks the link.
Private line plus VPN backup
ExpressRoute as the primary path with VPN as the standby route, tested regularly.
Zero trust inside the tunnel
Treat tunnel traffic as untrusted. Filter with NSGs and a firewall and segment access by role.
Private endpoints over VPN
Reach platform services through private addresses with public access switched off.
Entra ID for remote access
Sign-in with MFA and conditional access, so identity controls who connects.
Everything as code
Gateways, connections, and policies in reviewed code, with secrets in Key Vault.
Anti-patterns to avoid
Context
A company connects its first office to Azure with one tunnel to one device, and the VPN becomes the path for the payment system.
The trap
The single device fails during a busy Saturday. There is no second path, no tested failover, and the person who knows the device is on holiday. The payment system is offline for hours.
The better way
Use two devices, an active-active gateway, and BGP, and rehearse a failure before go-live. Document who owns each device and keep a spare or a quick replacement plan.
Context
Two teams each pick the default range 10.0.0.0/16 for their networks, and later a project needs them connected.
The trap
The ranges overlap, so routing cannot tell which network a packet belongs to. The fix requires renumbering live systems or adding NAT, both of which are slow and risky.
The better way
Maintain a central address plan, allocate ranges before anything is built, and avoid common defaults. Review the plan before every new network or acquisition.
Context
The pre-shared key for a tunnel is a short word chosen at set-up, pasted into a team chat, and never changed.
The trap
The key is guessable and widely visible. Years later, a former contractor still knows it, and anyone who sees the chat history can attempt to impersonate the on-premises side.
The better way
Use a long random key stored in Key Vault, share it only through secure channels, and rotate it regularly and on staff changes. Prefer certificate-based or identity-based authentication where possible.
Context
A team believes that because all traffic arrives through an encrypted tunnel, security rules inside the virtual network are unnecessary.
The trap
A single infected laptop on the office network now has free access to every server in Azure. The tunnel faithfully carries the attack straight in.
The better way
Segment the network, apply least-privilege NSG rules, inspect traffic with a firewall, and log everything. Assume that any connected device could be compromised.
More anti-patterns in brief
- A gateway subnet that is too small. No room for upgrades, coexistence with ExpressRoute, or growth.
- A gateway per spoke. Costly and hard to manage when gateway transit would do.
- Judging performance with one speed test. Single flows are limited by latency, not by the gateway.
- Using a VPN for huge one-off data loads. An offline device or private circuit is faster and cheaper.
- Leaving unused tunnels and users. They add risk and clutter and serve no purpose.
- Forgetting DNS. Systems connect by IP address in testing and break in production.
19Best Practices, Cost Awareness, and Common Mistakes
This chapter gathers the habits that separate calm operations from late-night panics, and explains where the money goes so that no bill is a surprise.
Where the cost comes from
A VPN gateway is billed mainly by the hour at a rate set by its SKU, whether or not any traffic is flowing. There are additional charges for the public IP address, for data leaving Azure (data coming in is generally free), and for some connection and tunnel features depending on the setup. Prices vary by region and change over time, so use Azure’s pricing calculator and the current price list for a real estimate.
| Cost driver | Why it grows | How to keep it sensible |
|---|---|---|
| Gateway hours | Billed continuously by SKU | Right-size the SKU, share one gateway among spokes, delete unused gateways |
| Zone-redundant SKU | Higher rate than non-zonal | Use for production, choose smaller sizes for development |
| Data transfer out | More traffic from Azure to on-premises or other regions | Keep chatty systems on the same side, compress, schedule bulk moves |
| Public IP addresses | One or two per gateway | Remove unused addresses |
| Extra gateways | One per network when sharing would do | Hub and spoke with gateway transit |
| Logs | Verbose diagnostic data stored for long periods | Choose categories and retention carefully |
Habits that pay off
Plan addresses and names first
Overlaps and DNS gaps are the most expensive mistakes to fix later.
Choose route-based, zone-redundant, active-active with BGP
This combination gives flexibility and strong resilience for production.
Use strong, matching cryptography
Set a custom policy where compliance requires it, and keep both sides identical.
Guard secrets and identities
Key Vault for keys, Entra ID with MFA for people, regular reviews for both.
Do not trust the tunnel
Segment, filter, and log inside the virtual network.
Monitor and alert
Tunnel state, bandwidth, drops, BGP, and configuration changes all deserve alerts.
Rehearse failure and keep a run book
You do not truly have redundancy until you have seen it work.
Common mistakes, in plain words
- Creating the gateway late. It takes half an hour or more to provision, which can stall a project.
- Attaching an NSG to the gateway subnet. It can break the gateway in ways that are hard to diagnose.
- Using policy-based gateways by habit. They lack features that route-based gateways offer.
- Forgetting to allow UDP 500, UDP 4500, and ESP. The tunnel then cannot form.
- Ignoring MTU. Small tests pass and real workloads hang.
- Allowing everything from the VPN range. A tunnel is a path, not a permission.
- Not refreshing client profiles. Remote users cannot see new ranges after changes.
- Never testing failover. The first real test then happens during an outage.
Write down three numbers that define your VPN: the peak aggregate bandwidth, the number of site tunnels, and the peak number of simultaneous remote users. Nearly every sizing and cost decision follows from them.
20Real-World Usage Scenarios
The scenarios below are illustrative composites that show how the ideas combine. The organisations are invented and the numbers are chosen to teach, not to describe any real company.
Scenario 1: A retail chain connects its stores
A retailer with 60 small stores uses an internet line and a small firewall in each. Every store establishes a site-to-site tunnel into a hub network in Azure, using BGP so new store networks are learned automatically. Each store gets a /24 from a reserved block. Point-of-sale systems talk to cloud services over the tunnels, and a second internet line at the bigger stores provides a backup tunnel. The central team manages everything as code, rotating keys yearly. When a store firewall fails, the team replaces it and the tunnel returns within minutes.
Scenario 2: A hospital group secures remote clinicians
A hospital group lets doctors review records from home. Doctors connect with the Azure VPN Client using OpenVPN and Microsoft Entra ID sign-in with multifactor authentication, allowed only from managed devices through conditional access. The client pool is a dedicated range, and NSG rules allow access only to the records application subnet. Logs go to a protected workspace, reviewed weekly. Access is removed automatically when an account is disabled.
Scenario 3: A migration with a safety net
A manufacturer moves its main applications to Azure over eighteen months. A high-capacity private circuit is ordered, but the lead time is eight weeks, so the team starts with an active-active VPN gateway and two tunnels. When the circuit arrives, the VPN stays in place as the backup, with routing set so that the circuit is preferred. During a later fibre cut at the data centre, traffic moves to the VPN automatically, slower but alive, and the team has a story to tell the auditors.
Scenario 4: A merger with overlapping addresses
Two companies merge, and both use the same private range for their main offices. Renumbering is planned for next year, but systems must talk now. The team uses the gateway’s NAT feature to present one company’s network to the other under a different, non-overlapping range. Applications use names, with DNS mapping to the translated addresses. It works well enough, and the plan to renumber is documented as a technical debt item with an owner and a date.
Scenario 5: A software team reaches private test servers
A development team keeps test databases on private addresses in Azure with no public access. Developers connect with point-to-site VPN and reach the databases through private endpoints. DNS is arranged so that database names resolve to private addresses over the tunnel. A new developer is up and running in an hour, with no firewall exceptions requested and nothing exposed to the internet.
Scenario 6: Solving a hanging file transfer
A finance team reports that their nightly file transfer over the tunnel stalls at the same point each night, even though the tunnel shows connected and small tests succeed. The engineer notices that ping works but large packets are lost. She lowers the segment size on the on-premises device, and the transfers complete. Afterwards, the team adds a large-packet test to the standard checks for any new tunnel.
What these scenarios share
In every case, success comes from planning addresses and names first, designing for failure, using identity and least privilege rather than trusting the tunnel, and testing both normal behaviour and failure. Teams that treat the VPN as a living service, with monitoring, run books, and regular reviews, keep it unremarkable, which is the best compliment a network can earn.
21Frequently Asked Questions
Short answers to the questions beginners ask most often.
22Summary and Key Takeaways
You began with the problem of linking private networks across a public internet, and you now have a complete map of Azure’s VPN service: what it is, how its tunnels are built and kept alive, how to route, secure, scale, watch, and repair it.
Think of VPN Gateway as an armoured van service with its own customs checkpoint. The van keeps the contents sealed on the public road, the checkpoint checks identity and keys at both ends, and the routes decide which goods go where. You supply the plan, the keys, and the rules, and Azure supplies the checkpoint and the staff. The better your address plan, your secrets, and your rehearsals, the more boring your VPN will be, and boring is exactly what you want from a network.
Key Takeaways
- It builds encrypted tunnels over the internet. Azure VPN Gateway supports site-to-site, point-to-site, and VNet-to-VNet connections, and a single gateway can serve all three. Choose route-based gateways and a current, zone-redundant SKU for new designs.
- Know the building blocks. The virtual network, the specially named GatewaySubnet, the gateway, its public IP, the local network gateway, and the connection with its shared key must all agree with the on-premises device.
- Tunnels are negotiated, not just switched on. IKE agrees on keys and algorithms, ESP carries the encrypted packets, and mismatched keys, policies, or blocked ports are the most common reasons a tunnel never forms.
- Plan addresses, routes, and names first. Overlapping ranges break VPNs, BGP keeps multiple paths healthy, hub-and-spoke with gateway transit saves cost, and DNS forwarding is what makes hybrid names work.
- Design for failure. Use active-active, zone-redundant gateways, two on-premises devices, BGP, and optionally ExpressRoute with VPN as the backup, and test the failover before you need it.
- Secure the keys, the people, and the inside. Use strong cryptography with perfect forward secrecy, long random keys in Key Vault, Entra ID with multifactor authentication for remote users, and NSGs, firewalls, and segmentation, because a tunnel is a path and not a permission.
- Measure, monitor, and keep it alive. Estimate throughput and latency limits before you start, watch tunnel state, bandwidth, drops, and BGP, keep a run book, and rotate keys and review access on a schedule.