|
| 1 | +--- |
| 2 | +title: 'How to configure virtual hub routing: Azure PowerShell' |
| 3 | +titleSuffix: Azure Virtual WAN |
| 4 | +description: Learn how to configure Virtual WAN virtual hub routing using Azure PowerShell. |
| 5 | +services: virtual-wan |
| 6 | +author: cherylmc |
| 7 | + |
| 8 | +ms.service: virtual-wan |
| 9 | +ms.topic: how-to |
| 10 | +ms.date: 10/26/2022 |
| 11 | +ms.author: cherylmc |
| 12 | + |
| 13 | +--- |
| 14 | +# How to configure virtual hub routing - Azure PowerShell |
| 15 | + |
| 16 | +A virtual hub can contain multiple gateways such as a site-to-site VPN gateway, ExpressRoute gateway, point-to-site gateway, and Azure Firewall. The routing capabilities in the virtual hub are provided by a router that manages all routing, including transit routing, between the gateways using Border Gateway Protocol (BGP). The virtual hub router also provides transit connectivity between virtual networks that connect to a virtual hub and can support up to an aggregate throughput of 50 Gbps. These routing capabilities apply to customers using **Standard** Virtual WANs. For more information, see [About virtual hub routing](about-virtual-hub-routing.md). |
| 17 | + |
| 18 | +This article helps you configure virtual hub routing using Azure PowerShell. You can also configure virtual hub routing using the [Azure portal steps](how-to-virtual-hub-routing.md). |
| 19 | + |
| 20 | +## Create a route table |
| 21 | + |
| 22 | +1. Get the virtual hub details to create route table. |
| 23 | + |
| 24 | + ```azurepowershell-interactive |
| 25 | + $virtualhub = Get-AzVirtualHub -ResourceGroupName "[resource group name]" -Name "[virtualhub name]" |
| 26 | + ``` |
| 27 | + |
| 28 | +1. Get VNet connection details to be used as next hop. |
| 29 | + |
| 30 | + ```azurepowershell-interactive |
| 31 | + $hubVnetConnection = Get-AzVirtualHubVnetConnection -Name "[HubconnectionName]" -ParentResourceName "[Hub Name]" -ResourceGroupName "[resource group name]" |
| 32 | + ``` |
| 33 | + |
| 34 | +1. Create a route to be associated with the virtual hub $virtualhub. The **-NextHop** is the virtual network connection $hubVnetConnection. Nexthop can be list of virtual network connections or Azure Firewall. |
| 35 | + |
| 36 | + ```azurepowershell-interactive |
| 37 | + $route = New-AzVHubRoute -Name "[Route Name]" -Destination “[@("Destination prefix")]” -DestinationType "CIDR" -NextHop $hubVnetConnection.Id -NextHopType "ResourceId" |
| 38 | + ``` |
| 39 | + |
| 40 | +1. Create the route table using the route object created in the previous step, $route, and associate it to the virtual hub $virtualhub. |
| 41 | + |
| 42 | + ```azurepowershell-interactive |
| 43 | + New-AzVHubRouteTable -Name "testRouteTable" -ParentObject $virtualhub -Route @($route) -Label @("testLabel") |
| 44 | + ``` |
| 45 | + |
| 46 | +## Delete a route table |
| 47 | + |
| 48 | +```azurepowershell-interactive |
| 49 | +Remove-AzVirtualHubRouteTable -ResourceGroupName "[resource group name]" -HubName "virtualhubname" -Name "routeTablename" |
| 50 | +``` |
| 51 | + |
| 52 | +## Update a route table |
| 53 | + |
| 54 | +The steps in this section help you update a route table. For example, update an existing route's next hop to an existing Azure Firewall. |
| 55 | + |
| 56 | +```azurepowershell-interactive |
| 57 | +$firewall = Get-AzFirewall -Name "[firewall name]]" -ResourceGroupName "[resource group name]" |
| 58 | +$newroute = New-AzVHubRoute -Name "[Route Name]" -Destination @("0.0.0.0/0") -DestinationType "CIDR" -NextHop $firewall.Id -NextHopType "ResourceId" |
| 59 | +Update-AzVHubRouteTable -ResourceGroupName "[resource group name]" -VirtualHubName ["virtual hub name"] -Name ["route table name"] -Route @($newroute) |
| 60 | +``` |
| 61 | + |
| 62 | +## Configure routing for a virtual network connection |
| 63 | + |
| 64 | +The steps in this section help you set up routing configuration for a virtual network connection. For example, adding static routes to an NVA appliance. |
| 65 | + |
| 66 | +* For this configuration, the route name should be the same as the one you used when you added a route earlier. Otherwise, you'll create two routes in the routing table: one without an IP address and one with an IP address. |
| 67 | +* The destination prefix can be one CIDR or multiple ones. For a single CIDR, use this format: `@("10.19.2.0/24")`. For multiple CIDRs, use this format: `@("10.19.2.0/24", "10.40.0.0/16")`. |
| 68 | + |
| 69 | +1. Define a static route to an NVA IP address. |
| 70 | + |
| 71 | + ```azurepowershell-interactive |
| 72 | + $staticRoute = New-AzStaticRoute -Name "[Route Name]" -A-AddressPrefix "[@("Destination prefix")]" -NextHopIpAddress "[Destination NVA IP address]" -NextHopIpAddress "[Destination NVA IP address]" |
| 73 | + ``` |
| 74 | + |
| 75 | +1. Define routing configuration. |
| 76 | + |
| 77 | + ```azurepowershell-interactive |
| 78 | + $associatedTable = Get-AzVHubRouteTable -ResourceGroupName "[resource group name]" -VirtualHubName $virtualhub.Name -Name "defaultRouteTable" |
| 79 | + $propagatedTable = Get-AzVHubRouteTable -ResourceGroupName "[resource group name]" -VirtualHubName $virtualhub.Name -Name "noneRouteTable" |
| 80 | + $updatedRoutingConfiguration= New-AzRoutingConfiguration -AssociatedRouteTable $associatedTable.Id -Label @("testLabel") -Id @($propagatedTable.Id) -StaticRoute @($staticRoute) |
| 81 | + ``` |
| 82 | + |
| 83 | +1. Update the existing virtual network connection. |
| 84 | + |
| 85 | + ```azurepowershell-interactive |
| 86 | + Update-AzVirtualHubVnetConnection -ResourceGroupName "[resource group name]" -VirtualHubName $virtualhub.Name -Name "[Virtual hub connection name]" -RoutingConfiguration $updatedRoutingConfiguration |
| 87 | + ``` |
| 88 | + |
| 89 | +1. Verify static route on the virtual network connection. |
| 90 | + |
| 91 | + ```azurepowershell-interactive |
| 92 | + Get-AzVirtualHubVnetConnection -ResourceGroupName "[Resource group]" -VirtualHubName "[virtual hub name]" -Name "[Virtual hub connection name]" |
| 93 | + ``` |
| 94 | + |
| 95 | +## Next steps |
| 96 | + |
| 97 | +* For more information about virtual hub routing, see [About virtual hub routing](about-virtual-hub-routing.md). |
| 98 | +* For more information about Virtual WAN, see the [Virtual WAN FAQ](virtual-wan-faq.md). |
0 commit comments