Virtual Networks Routes Overview
This document provides a comprehensive overview of route tables and their role in defining traffic flow within Azure Virtual Networks.
Understanding Route Tables
Route tables in Azure Virtual Networks (VNet) allow you to override the default system routes. By default, Azure automatically creates routes for subnets within a VNet. However, for more complex network topologies and traffic control, you can create custom route tables.
Key Concepts
- Route Table: A collection of routes that determine how network traffic is directed.
- Route: A rule that specifies how to route traffic destined for a particular IP address prefix.
- Next Hop: The destination where the traffic is sent next, based on a route.
How Route Tables Work
When a virtual machine (VM) or other resource within a subnet sends network traffic, Azure checks the associated route table for a matching route. If a match is found, Azure forwards the traffic to the specified next hop. If no custom route matches, Azure uses its default system routes.
Next Hop Types
The following are common next hop types you can define in a route:
- Virtual Appliance: Traffic is sent to a network virtual appliance (NVA) such as a firewall or intrusion detection system.
- Virtual Network Gateway: Traffic is sent to an Azure Virtual Network Gateway, typically for VPN or ExpressRoute connectivity.
- Internet: Traffic is sent directly to the internet.
- None: Traffic is dropped. This is often used for security purposes.
- Virtual Network: Traffic is sent to another subnet within the same VNet (default behavior).
Creating and Managing Route Tables
Route tables can be created and managed through the Azure portal, Azure PowerShell, or Azure CLI. When you create a route table, you associate it with one or more subnets.
Steps to Create a Route Table (Azure Portal)
- Navigate to the Azure portal.
- Search for "Route Tables" and select it.
- Click "Create".
- Fill in the required details: Subscription, Resource Group, Name, Region.
- Click "Review + create" and then "Create".
- Once created, select the route table and go to "Routes" to add custom routes.
- Go to "Subnets" to associate the route table with your desired subnets.
Use Cases for Custom Routes
Custom routes are essential for implementing various network architectures:
- Network Virtual Appliances (NVAs): Forcing all traffic through a firewall or other security appliance.
- Hub-and-Spoke Topologies: Directing traffic between spokes and the hub network.
- ExpressRoute/VPN Gateways: Ensuring on-premises traffic is routed correctly.
- Traffic Inspection: Redirecting traffic to monitoring or logging services.
Important Note on Route Propagation
Routes learned from BGP (Border Gateway Protocol) via VPN Gateway or ExpressRoute are automatically propagated to the subnets associated with the route table. Custom routes you define take precedence over system routes but are generally overridden by BGP routes unless specifically configured otherwise.
Route Table Limitations
- A VNet can have multiple route tables associated with its subnets.
- Each subnet can only be associated with one route table.
- Routes are evaluated in the following order: most specific match, longest prefix match.
- Maximum of 400 custom routes per route table.
Example: Forcing Traffic Through a Firewall
Consider a scenario where you want to inspect all inbound and outbound traffic from a specific subnet. You can achieve this by:
- Deploying a Network Virtual Appliance (NVA) like an Azure Firewall or a third-party firewall.
- Creating a route table.
- Adding a route with the address prefix
0.0.0.0/0(representing all internet traffic). - Setting the next hop to the NVA.
- Associating this route table with the subnet containing your resources.
This ensures that all traffic originating from or destined for that subnet is first routed to the NVA for inspection before being sent to its final destination.
| Type | Description |
|---|---|
| Virtual Appliance | Traffic is sent to an IP address of a network virtual appliance in the VNet. |
| Virtual Network Gateway | Traffic is sent to a Virtual Network Gateway for VPN or ExpressRoute. |
| Internet | Traffic is routed to the internet. |
| None | Traffic is dropped. |
| Virtual Network | Traffic is routed to another subnet within the same VNet. |
Performance Considerations
While route tables offer flexibility, be mindful of the performance impact when routing traffic through NVAs. Ensure your NVAs are sized appropriately to handle the expected network load.