共用方式為


設定 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
在您的瀏覽器中開啟 Cloud Shell。 https://shell.azure.com/powershell
按一下 Azure 入口網站右上方功能表上的 [Cloud Shell] 按鈕。 入口網站中的 Cloud Shell

識別線路

  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 訂用帳戶中,您需要授權。 若要設定連線,請遵循下列步驟:

  1. 在線路 2 的訂用帳戶中產生授權金鑰:

    $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 的訂用帳戶中設定連線:

    針對線路 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"

若要檢查 CircuitConnectionStatus 在 PowerShell 中執行 $ckt_1 。 指出連線是 連線已中斷連線

停用連線

若要停用內部部署網路之間的連線,請針對設定的線路執行下列命令(例如上一個範例中的線路 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

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

完成這些步驟之後,您就無法再透過 ExpressRoute 線路在內部部署網路之間連線。

更新連線和設定

若要更新 Global Reach 連線設定,請遵循下列步驟:

  1. 擷取 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"
    
  2. 定義新的位址空間與地址前置字碼型態:

    $addressSpace = 'aa:bb::0/125'
    $addressPrefixType = 'IPv6'
    
  3. 更新連線設定:

    Set-AzExpressRouteCircuitConnectionConfig -Name "Your_connection_name" -ExpressRouteCircuit $ckt_1 -PeerExpressRouteCircuitPeering $ckt_2.Peerings[0].Id -AddressPrefix $addressSpace -AddressPrefixType $addressPrefixType
    
  4. 儲存更新的組態:

    Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt_1
    

下一步

  1. 深入了解 ExpressRoute 觸角擴及全球
  2. 驗證 ExpressRoute 連線
  3. 將 ExpressRoute 線路連結到 Azure 虛擬網路