設定 ExpressRoute Global Reach

本文可協助您使用 PowerShell 設定 ExpressRoute Global Reach。 如需詳細資訊,請參閱 ExpressRoute Global Reach

開始之前

開始設定之前,請先確認下列資訊:

  • 您瞭解 ExpressRoute 線路布建 工作流程
  • 您的 ExpressRoute 線路處於已佈建狀態。
  • 您的 ExpressRoute 線路上已設定 Azure 私人對等互連。
  • 如果您想要在本機執行 PowerShell,請確認您的電腦上已安裝最新版本的 Azure PowerShell。

使用 Azure PowerShell

本文中的步驟和範例會使用 Azure PowerShell Az 模組。 若要在您的電腦本機上安裝 Az 模組,請參閱安裝 Azure PowerShell。 若要深入了解新的 Az 模組,請參閱新的 Azure PowerShell Az 模組簡介。 PowerShell Cmdlet 會經常更新。 如果您未執行最新版本,指示中指定的值可能會失敗。 若要在您的系統上尋找已安裝的 PowerShell 版本,請使用 Get-Module -ListAvailable Az Cmdlet。

您可以使用 Azure Cloud Shell 來執行大部分的 PowerShell Cmdlet 和 CLI 命令,而不用在本機安裝 Azure PowerShell 或 CLI。 Azure Cloud Shell 是一個免費的互動式殼層,具有預先安裝和設定的通用 Azure 工具,可與您的帳戶搭配使用。 若要在 Azure Cloud Shell 上執行本文所包含的任何程式碼,請開啟 Cloud Shell 工作階段、使用某個程式碼區塊上的 [複製] 按鈕來複製程式碼,然後使用 Ctrl+Shift+V (在 Windows 和 Linux 上) 或 Cmd+Shift+V (在 macOS 上) 將程式碼貼到 Cloud Shell 工作階段中。 貼上的文字不會自動執行,請按下 Enter 鍵來執行程式碼。

以下有幾種啟動 Cloud Shell 的方式:

選項 連結
按一下程式碼區塊右上角的 [試試看] Cloud Shell in this article
在您的瀏覽器中開啟 Cloud Shell。 https://shell.azure.com/powershell
按一下 Azure 入口網站右上方功能表上的 [Cloud Shell] 按鈕。 Cloud Shell in the portal

識別線路

  1. 若要啟動設定,請登入您的 Azure 帳戶,然後選取您想要使用的訂用帳戶。

    如果您使用 Azure Cloud Shell,您可以在按一下 [試用] 之後自動登入您的 Azure 帳戶。 若要在本機登入,請以提高的權限開啟 PowerShell 主控台並執行 Cmdlet 以連線。

    Connect-AzAccount
    

    如果您有多個訂用帳戶,請取得 Azure 訂用帳戶的清單。

    Get-AzSubscription
    

    指定您要使用的訂用帳戶。

    Select-AzSubscription -SubscriptionName "Name of subscription"
    
  2. 識別您想要使用的 ExpressRoute 線路。 您可以啟用任兩個 ExpressRoute 線路的私人對等互連之間的 ExpressRoute Global Reach,只要它們位於支援的國家/地區,而且是在不同的對等互連位置建立。

    • 如果您的訂用帳戶擁有這兩個線路,您可以選擇任一線路來執行下列各節中的組態。
    • 如果兩個線路位於不同的 Azure 訂用帳戶中,您需要其中一個 Azure 訂用帳戶的授權。 然後在另一個 Azure 訂用帳戶中執行組態命令時,傳入授權金鑰。

注意

ExpressRoute Global Reach 設定只能從設定的線路中看到。

啟用連線

在內部部署網路之間啟用連線。 位在相同 Azure 訂閱的線路,以及屬於不同訂閱的線路會有不同組的線路指示。

相同 Azure 訂閱中的 ExpressRoute 線路

  1. 使用下列命令來取得線路 1 和線路 2。 這兩個線路位於相同的訂用帳戶中。

    $ckt_1 = Get-AzExpressRouteCircuit -Name "Your_circuit_1_name" -ResourceGroupName "Your_resource_group"
    $ckt_2 = Get-AzExpressRouteCircuit -Name "Your_circuit_2_name" -ResourceGroupName "Your_resource_group"
    
  2. 針對線路 1 執行下列命令,並傳入線路 2 的私人對等互連標識符。

    • 私人對等互連標識碼看起來類似下列範例:

      /subscriptions/{your_subscription_id}/resourceGroups/{your_resource_group}/providers/Microsoft.Network/expressRouteCircuits/{your_circuit_name}/peerings/AzurePrivatePeering
      
    • -AddressPrefix 必須是 /29 IPv4 子網,例如 10.0.0.0/29。 我們會使用此子網中的IP位址來建立兩個ExpressRoute線路之間的連線。 您不應該在 Azure 虛擬網路或內部部署網路中使用此子網中的位址。

      Add-AzExpressRouteCircuitConnectionConfig -Name 'Your_connection_name' -ExpressRouteCircuit $ckt_1 -PeerExpressRouteCircuitPeering $ckt_2.Peerings[0].Id -AddressPrefix '__.__.__.__/29'
      

      注意

      如果您想要啟用 ExpressRoute Global Reach 的 IPv6 支援,您必須為 -AddressPrefix 指定 /125 IPv6 子網,以及 IPv6-AddressPrefixType

      Add-AzExpressRouteCircuitConnectionConfig -Name 'Your_connection_name' -ExpressRouteCircuit $ckt_1 -PeerExpressRouteCircuitPeering $ckt_2.Peerings[0].Id -AddressPrefix '__.__.__.__/125' -AddressPrefixType IPv6
      
  3. 將組態儲存在線路 1 上,如下所示:

    Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt_1
    

當先前的作業完成時,您會透過兩個 ExpressRoute 線路,在兩端的內部部署網路之間連線。

不同 Azure 訂用帳戶中的 ExpressRoute 線路

如果兩個線路不在相同的 Azure 訂用帳戶中,您需要授權。 在下列組態中,會在線路 2 訂用帳戶中產生授權,並將授權密鑰傳遞至線路 1。

  1. 產生授權金鑰。

    $ckt_2 = Get-AzExpressRouteCircuit -Name "Your_circuit_2_name" -ResourceGroupName "Your_resource_group"
    Add-AzExpressRouteCircuitAuthorization -ExpressRouteCircuit $ckt_2 -Name "Name_for_auth_key"
    Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt_2
    

    記下線路 2 的私人對等互連標識符和授權金鑰。

  2. 針對線路 1 執行下列命令。 傳入線路 2 和授權金鑰的私人對等互連標識碼。

    Add-AzExpressRouteCircuitConnectionConfig -Name 'Your_connection_name' -ExpressRouteCircuit $ckt_1 -PeerExpressRouteCircuitPeering "circuit_2_private_peering_id" -AddressPrefix '__.__.__.__/29' -AuthorizationKey '########-####-####-####-############'
    

    注意

    如果您想要啟用 ExpressRoute Global Reach 的 IPv6 支援,您必須為 -AddressPrefix 指定 /125 IPv6 子網,以及 IPv6-AddressPrefixType

    Add-AzExpressRouteCircuitConnectionConfig -Name 'Your_connection_name' -ExpressRouteCircuit $ckt_1 -PeerExpressRouteCircuitPeering $ckt_2.Peerings[0].Id -AddressPrefix '__.__.__.__/125' -AddressPrefixType IPv6 -AuthorizationKey '########-####-####-####-############'
    
  3. 將組態儲存在線路 1 上。

    Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt_1
    

當先前的作業完成時,您會透過兩個 ExpressRoute 線路,在兩端的內部部署網路之間連線。

驗證設定

使用下列命令來驗證組態在進行設定的線路上設定(例如上一個範例中的線路 1)。

$ckt_1 = Get-AzExpressRouteCircuit -Name "Your_circuit_1_name" -ResourceGroupName "Your_resource_group"

如果您只是在 PowerShell 中執行 $ckt_1,您會在輸出中看到 Circuit 連線 ionStatus。 它會告訴您是否已建立連線、連線 或已中斷連線

停用連線

若要停用內部部署網路之間的連線,請針對設定的線路執行命令(例如上一個範例中的線路 1)。

$ckt_1 = Get-AzExpressRouteCircuit -Name "Your_circuit_1_name" -ResourceGroupName "Your_resource_group"
Remove-AzExpressRouteCircuitConnectionConfig -Name "Your_connection_name" -ExpressRouteCircuit $ckt_1
Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt_1

注意

若要刪除 IPv6 Global Reach 連線,您必須在下列命令中指定 IPv6-AddressPrefixType

$ckt_1 = Get-AzExpressRouteCircuit -Name "Your_circuit_1_name" -ResourceGroupName "Your_resource_group"
Remove-AzExpressRouteCircuitConnectionConfig -Name "Your_connection_name" -ExpressRouteCircuit $ckt_1 -AddressPrefixType IPv6
Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt_1

您可以執行取得作業來驗證狀態。

完成先前的作業之後,您就無法再透過 ExpressRoute 線路在內部部署網路之間連線。

更新連線設定

若要更新 Global Reach 連線設定,請對其中一個 ExpressRoute 線路執行下列命令。

$ckt_1 = Get-AzExpressRouteCircuit -Name "Your_circuit_1_name" -ResourceGroupName "Your_resource_group"
$ckt_2 = Get-AzExpressRouteCircuit -Name "Your_circuit_2_name" -ResourceGroupName "Your_resource_group"
$addressSpace = 'aa:bb::0/125'
$addressPrefixType = 'IPv6'
Set-AzExpressRouteCircuitConnectionConfig -Name "Your_connection_name" -ExpressRouteCircuit $ckt_1 -PeerExpressRouteCircuitPeering $ckt_2.Peerings[0].Id -AddressPrefix $addressSpace -AddressPrefixType $addressPrefixType
Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt_1

下一步

  1. 深入瞭解 ExpressRoute Global Reach
  2. 驗證 ExpressRoute 連線
  3. 將 ExpressRoute 線路連結至 Azure 虛擬網路