Virtual Network Routing

Learn how to control traffic flow within your Azure virtual network and to external networks using route tables and user-defined routes.

Understanding Azure VNet Routing

Azure virtual networks (VNets) provide a robust platform for defining your private cloud environment in Azure. Network traffic within a VNet and between VNets, on-premises networks, and the internet is routed by default. However, you can override this default behavior to control traffic flow using user-defined routes (UDRs) and route tables.

Default System Routes

By default, Azure automatically creates system routes for traffic based on the network topology. These include:

You cannot modify or delete system routes, but you can add your own routes that take precedence.

User-Defined Routes (UDRs)

User-defined routes allow you to influence how traffic is routed from a subnet. You can create a route table and associate it with one or more subnets. When a route table is associated with a subnet, the routes in the table are applied to traffic originating from that subnet. UDRs can be used for various scenarios, such as:

Creating a Route Table

You can create a route table using the Azure portal, Azure CLI, or Azure PowerShell.

Azure Portal Steps:

  1. In the Azure portal, search for and select "Route tables".
  2. Click "Create".
  3. Provide a name, subscription, resource group, and region.
  4. Click "Review + create", then "Create".

Adding Routes to a Route Table

Once a route table is created, you can add routes to it:

  1. Navigate to your created route table.
  2. Under "Settings", click "Routes".
  3. Click "+ Add".
  4. Enter a route name, address prefix (CIDR block), next hop type (e.g., Virtual appliance, Internet, Virtual network gateway, None), and next hop address (if applicable).
  5. Click "Add".

Associating a Route Table with a Subnet

To apply the routes in your route table, you need to associate it with a subnet:

  1. Navigate to your created route table.
  2. Under "Settings", click "Subnets".
  3. Click "+ Associate".
  4. Select the virtual network and the subnet you want to associate.
  5. Click "OK".

Next Hop Types

The Next hop type specifies where the traffic should be sent:

Next Hop Type Description
Virtual appliance Traffic is routed to a network virtual appliance (NVA) like a firewall or load balancer. You must specify the IP address of the NVA's network interface.
Internet Traffic is routed to the public internet.
Virtual network gateway Traffic is routed to an Azure VPN Gateway or ExpressRoute gateway for on-premises connectivity.
None Traffic is dropped. Use this for security purposes to block specific traffic.
VNetLocal Traffic is routed within the virtual network. This is the default behavior.

Route Propagation

Routes can propagate from connected networks (e.g., VPN Gateway, ExpressRoute) to your VNet. This allows for dynamic route updates without manual intervention.

Note: When multiple routes match a destination IP address, Azure selects the most specific route. If routes have the same prefix length, the following priority order is used: User-defined route, VPN gateway route, VNet gateway route, and finally, system routes.

Troubleshooting Routing Issues

Use the IP Flow Verify and Connection Troubleshoot features in Azure Network Watcher to diagnose connectivity issues and verify routing configurations.

Best Practices

! IMPORTANT: Misconfigured routes can disrupt network connectivity. Always test routing changes thoroughly in a non-production environment before applying them to production VNets.