你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

部署双堆栈 Azure 网关负载均衡器

在本教程中,将 IPv6 配置部署到配置了 IPv4 的现有 Azure 网关负载均衡器。

学习内容:

  • 将 IPv6 地址范围添加到现有子网。
  • 将 IPv6 前端添加到网关负载均衡器。
  • 将 IPv6 后端池添加到网关负载均衡器。
  • 将 IPv6 配置添加到网络接口。
  • 为 IPv6 流量添加负载均衡规则。
  • 将 IPv6 负载均衡器前端链接到网关负载均衡器。

除了网关负载均衡器,此方案还包括以下已部署的资源:

  • 双堆栈虚拟网络和子网。
  • 具有双(IPv4 + IPv6)前端配置的标准负载均衡器。
  • 仅具有 IPv4 的网关负载平衡器。
  • 具有双堆栈 IP 配置的网络接口、附加的网络安全组和公共 IPv4 和 IPv6 地址。

先决条件

将 IPv6 地址范围添加到现有子网

本文假定你已为 IPv4 流量配置了网关负载均衡器,其中包含相应的 VNET 和子网。 在此步骤中,将 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 负载均衡器前端链接到网关负载均衡器

在此最后一步中,将现有标准负载均衡器的 IPv6 前端链接到网关负载均衡器的 IPv6 前端。 现在,前往标准负载均衡器前端的所有 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。
  • 实现链接时,标准和网关负载均衡器前端配置的 IP 地址版本必须匹配。

后续步骤