Share via


部署雙堆疊 Azure 閘道負載平衡器

在本教學課程中,您會將 IPv6 設定部署到現有的 IPv4 設定 Azure 閘道負載平衡器。

您會學習:

  • 將 IPv6 位址範圍新增至現有的子網路。
  • 將 IPv6 前端新增至閘道負載平衡器。
  • 將 IPv6 後端集區新增至閘道負載平衡器。
  • 將 IPv6 設定新增至網路介面。
  • 新增 IPv6 流量的負載平衡規則。
  • 將 IPv6 負載平衡器前端鏈結到閘道負載平衡器。

除了閘道負載平衡器,此案例還包含下列已部署的資源:

  • 雙重堆疊虛擬網路和子網路。
  • 具雙重 (IPv4 + IPv6) 前端設定的 Standard Load Balancer。
  • 只有 IPv4 的閘道負載平衡器。
  • 具有雙堆疊 IP 設定、已連結網路安全性群組,和公用 IPv4 和 IPv6 位址的網路介面。

必要條件

將 IPv6 位址範圍新增至現有的子網路

本文會假設您已使用對應的 VNET 和子網路,針對 IPv4 流量設定閘道負載平衡器。 在此步驟中,您會將 IPv6 範圍新增至閘道負載平衡器的 VNET 和子網路。 使用此子網路/VNET 的私人 IP 位址,為閘道負載平衡器建立 IPv6 前端設定時,需要此範圍。


#Add IPv6 ranges to the VNET and subnet
#Retrieve the VNET object
$rg = Get-AzResourceGroup  -ResourceGroupName "myResourceGroup"
$vnet = Get-AzVirtualNetwork  -ResourceGroupName $rg.ResourceGroupName -Name "myVNet"  

#Add IPv6 prefix to the VNET
$vnet.addressspace.addressprefixes.add("fd00:db8:deca::/48")

#Update the running VNET
$vnet |  Set-AzVirtualNetwork

#Retrieve the subnet object from the local copy of the VNET
$subnet= $vnet.subnets[0]

#Add IPv6 prefix to the subnet
$subnet.addressprefix.add("fd00:db8:deca::/64")

#Update the running VNET with the new subnet configuration
$vnet |  Set-AzVirtualNetwork

將 IPv6 前端新增至閘道負載平衡器

既然您已將 IPv6 前置詞範圍新增至閘道負載平衡器的子網路和 VNET,我們可以在閘道負載平衡器上建立新的 IPv6 前端設定,並從子網路的範圍建立 IPv6 位址。


# Retrieve the load balancer configuration
$gwlb = Get-AzLoadBalancer -ResourceGroupName "myResourceGroup"-Name "myGatewayLoadBalancer"

# Add IPv6 frontend configuration to the local copy of the load balancer configuration
$gwlb | Add-AzLoadBalancerFrontendIpConfig `
     -Name "myGatewayFrontEndv6" `
     -PrivateIpAddressVersion "IPv6" `
     -Subnet $subnet

#Update the running load balancer with the new frontend
$gwlb | Set-AzLoadBalancer 

將 IPv6 後端集區新增至閘道負載平衡器

若要散發 IPv6 流量,您需要包含具有 IPv6 位址之執行個體的後端集區。 首先,您會在閘道負載平衡器上建立後端集區。 在下列步驟中,您會針對 IPv4 流量建立現有後端 NIC 的 IPv6 設定,並將其連結至此後端集區。


## Create IPv6 tunnel interfaces
$int1 = @{
    Type = 'Internal'
    Protocol = 'Vxlan'
    Identifier = '866'
    Port = '2666'
}
$tunnelInterface1 = New-AzLoadBalancerBackendAddressPoolTunnelInterfaceConfig @int1

$int2 = @{
    Type = 'External'
    Protocol = 'Vxlan'
    Identifier = '867'
    Port = '2667'
}
$tunnelInterface2 = New-AzLoadBalancerBackendAddressPoolTunnelInterfaceConfig @int2

# Create the IPv6 backend pool
$pool = @{
    Name = 'myGatewayBackendPoolv6'
    TunnelInterface = $tunnelInterface1,$tunnelInterface2
}

# Add the backend pool to the load balancer
$gwlb | Add-AzLoadBalancerBackendAddressPoolConfig @pool

# Update the load balancer
$gwlb | Set-AzLoadBalancer

將 IPv6 設定新增至網路介面


#Retrieve the NIC object
$NIC_1 = Get-AzNetworkInterface -Name "myNic1" -ResourceGroupName $rg.ResourceGroupName


$backendPoolv6 = Get-AzLoadBalancerBackendAddressPoolConfig -Name "myGatewayBackendPoolv6" -LoadBalancer $gwlb

#Add an IPv6 IPconfig to NIC_1 and update the NIC on the running VM
$NIC_1 | Add-AzNetworkInterfaceIpConfig -Name myIPv6Config -Subnet $vnet.Subnets[0]  -PrivateIpAddressVersion IPv6 -LoadBalancerBackendAddressPool $backendPoolv6 
$NIC_1 | Set-AzNetworkInterface


新增 IPv6 流量的負載平衡規則

負載平衡規則會決定如何將流量路由傳送至後端執行個體。 針對閘道負載平衡器,您可以建立已啟用 HA 連接埠的負載平衡規則,以便檢查所有通訊協定的流量,並抵達所有連接埠。


# Retrieve the updated (live) versions of the frontend and backend pool, and existing health probe
$frontendIPv6 = Get-AzLoadBalancerFrontendIpConfig -Name "myGatewayFrontEndv6" -LoadBalancer $gwlb
$backendPoolv6 = Get-AzLoadBalancerBackendAddressPoolConfig -Name "myGatewayBackendPoolv6" -LoadBalancer $gwlb
$healthProbe = Get-AzLoadBalancerProbeConfig -Name "myHealthProbe" -LoadBalancer $gwlb

# Create new LB rule with the frontend and backend
$gwlb | Add-AzLoadBalancerRuleConfig `
  -Name "myRulev6" `
  -FrontendIpConfiguration $frontendIPv6 `
  -BackendAddressPool $backendPoolv6 `
  -Protocol All `
  -FrontendPort 0 `
  -BackendPort 0 `
  -Probe $healthProbe

#Finalize all the load balancer updates on the running load balancer
$gwlb | Set-AzLoadBalancer
 

將 IPv6 負載平衡器前端鏈結到閘道負載平衡器

在此最後步驟中,您會將現有的 Standard Load Balancer IPv6 前端鏈結至閘道負載平衡器的 IPv6 前端。 現在,前往 Standard Load Balancer 的前端的所有 IPv6 流量都會轉送至您的閘道負載平衡器,以供已設定的 NVA 在到達應用程式之前進行檢查。


## Place the existing Standard load balancer into a variable. ##
$par1 = @{
    ResourceGroupName = 'myResourceGroup'
    Name = 'myLoadBalancer'
}
$lb = Get-AzLoadBalancer @par1

## Place the public frontend IP of the Standard load balancer into a variable.
$par3 = @{
    ResourceGroupName = 'myResourceGroup'
    Name = 'myIPv6PublicIP'
}
$publicIP = Get-AzPublicIPAddress @par3

## Chain the Gateway load balancer to your existing Standard load balancer frontend. ##
# $feip = Get-AzLoadBalancerFrontendIpConfig -Name "myGatewayFrontEndv6" -LoadBalancer $gwlb

$par4 = @{
    Name = 'myIPv6FrontEnd'
    PublicIPAddress = $publicIP 
    LoadBalancer = $lb
    GatewayLoadBalancerId = $feip.id
}
$config = Set-AzLoadBalancerFrontendIpConfig @par4

$config | Set-AzLoadBalancer

限制

  • 閘道負載平衡器不支援 NAT 64/46。
  • 當您實作鏈結時,Standard Load Balancer 和閘道負載平衡器前端設定的 IP 位址版本必須相符。

下一步