Azure Networking
Azure Route Tables
This article explains how to create and manage route tables in Azure. Route tables allow you to define custom routes to direct network traffic in your Azure virtual network.
What are Route Tables?
A route table contains a collection of rules, called routes, that determine where network traffic is directed. Azure uses route tables to override the system's default routes. You can associate a route table with one or more subnets in a virtual network. When you associate a route table with a subnet, all network traffic originating from that subnet uses the routes defined in the route table.
Key Concepts
- Route Table: A collection of routes.
- Route: A rule that defines a destination prefix and a next hop.
- Next Hop: The type of next hop that traffic should be directed to (e.g., Virtual Appliance, VNet Gateway, Internet).
- Association: Linking a route table to a subnet.
Creating a Route Table
You can create a route table using the Azure portal, Azure CLI, or Azure PowerShell.
Using Azure Portal:
- Navigate to the Azure portal.
- Search for "Route Tables" and select it.
- Click "+ Create" to start the creation process.
- Fill in the required details: Subscription, Resource group, Name, Region.
- Select "Propagate gateway routes" if you want to propagate routes from VPN or ExpressRoute gateways.
- Click "Review + create" and then "Create".
Adding Routes to a Route Table
Once a route table is created, you can add custom routes:
- Go to the route table resource in the Azure portal.
- Under "Settings", select "Routes".
- Click "+ Add".
- Provide a "Route name", "Address prefix" (e.g.,
10.1.0.0/16
), and select the "Next hop type" and "Next hop address" (if applicable). - Click "Add".
Associating a Route Table with a Subnet
To apply the custom routes, associate the route table with a subnet:
- Navigate to the route table resource.
- Under "Settings", select "Subnets".
- Click "+ Associate".
- Select the Virtual Network and the Subnet you want to associate.
- Click "OK".
Example: Routing traffic through a Network Virtual Appliance (NVA)
To force traffic through a firewall or other NVA, you would create a route for your desired traffic destination and set the "Next hop type" to Virtual Appliance
, providing the private IP address of the NVA as the "Next hop address".
// Example Azure CLI command to create a route
az network route-table route create \
--resource-group MyResourceGroup \
--route-table-name MyRouteTable \
--name RouteToNVA \
--address-prefix 0.0.0.0/0 \
--next-hop-type VirtualAppliance \
--next-hop-ip-address 10.0.1.4
API Reference
For programmatic management of route tables, refer to the Azure REST API documentation.
Resource | Description |
---|---|
Route Tables | Create, update, delete, and manage route tables. |
Routes | Add, update, and delete routes within a route table. |
Subnet Associations | Associate or disassociate route tables with subnets. |