首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于创建现有负载均衡器的新入站NAT池的powershell命令

用于创建现有负载均衡器的新入站NAT池的powershell命令
EN

Stack Overflow用户
提问于 2019-10-18 05:01:50
回答 2查看 399关注 0票数 0

我希望将现有的Azure负载均衡器附加到虚拟机刻度集中,为此,我需要创建入站nat池,以便能够获取入站nat池的资源ID,并将其传递给VMSS的ARM模板。提前谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-10-18 06:17:43

根据我的研究,我们可以使用PowerShell命令New-AzLoadBalancerInboundNatPoolConfig创建入站nat池。有关更多细节,请参阅https://learn.microsoft.com/en-us/powershell/module/az.network/New-AzLoadBalancerInboundNatPoolConfig?view=azps-2.8.0

例如:

代码语言:javascript
复制
Connect-AzAccount

$slb = Get-AzLoadBalancer -Name "testload" -ResourceGroupName "testfun07"
$feIpConfig = Get-AzLoadBalancerFrontendIpConfig -Name "LoadBalancerFrontEnd" -Loadbalancer $slb

New-AzLoadBalancerInboundNatPoolConfig -Name "myInboundNatPool" -FrontendIpConfigurationId $feIpConfig.Id -Protocol TCP -FrontendPortRangeStart 1001 -FrontendPortRangeEnd 2000 -BackendPort 1001

更新

如果要使用PowerShell为现有负载均衡器创建入站NAT池,则需要执行以下步骤

  1. 创建入站NAT池

代码语言:javascript
复制
$slb = Get-AzureRmLoadBalancer -Name "testload" -ResourceGroupName "testfun07"

$feIpConfig = Get-AzureRmLoadBalancerFrontendIpConfig -Name "LoadBalancerFrontEnd" -Loadbalancer $slb

Add-AzureRmLoadBalancerInboundNatPoolConfig -LoadBalancer $slb -Name "myInboundNatPool" -FrontendIpConfigurationId $feIpConfig.Id -Protocol TCP -FrontendPortRangeStart 1001 -FrontendPortRangeEnd 2000 -BackendPort 1001

  1. 为laad平衡器

配置ppol

代码语言:javascript
复制
Set-AzureRmLoadBalancerInboundNatPoolConfig -LoadBalancer $slb -Name "myInboundNatPool" -FrontendIpConfigurationId $feIpConfig.Id -Protocol TCP -FrontendPortRangeStart 1001 -FrontendPortRangeEnd 2000 -BackendPort 1001

  1. 更新负载均衡器

代码语言:javascript
复制
Set-AzureRmLoadBalancer -LoadBalancer $slb

例如

代码语言:javascript
复制
$name = "you account"
$password = "password"
$secpasswd = ConvertTo-SecureString $password -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($name, $secpasswd)
Connect-AzureRmAccount -Credential $mycreds 

$slb = Get-AzureRmLoadBalancer -Name "testload" -ResourceGroupName "testfun07"

$feIpConfig = Get-AzureRmLoadBalancerFrontendIpConfig -Name "LoadBalancerFrontEnd" -Loadbalancer $slb

Add-AzureRmLoadBalancerInboundNatPoolConfig -LoadBalancer $slb -Name "myInboundNatPool" -FrontendIpConfigurationId $feIpConfig.Id -Protocol TCP -FrontendPortRangeStart 1001 -FrontendPortRangeEnd 2000 -BackendPort 1001
 "1" | Out-File -FilePath E:\mytest.txt -Append -Encoding utf8

Get-AzureRmLoadBalancer -Name "testload" -ResourceGroupName "testfun07" | Select-Object InboundNatPools | fl | Out-File -FilePath E:\mytest.txt -Append -Encoding utf8



Set-AzureRmLoadBalancerInboundNatPoolConfig -LoadBalancer $slb -Name "myInboundNatPool" -FrontendIpConfigurationId $feIpConfig.Id -Protocol TCP -FrontendPortRangeStart 1001 -FrontendPortRangeEnd 2000 -BackendPort 1001

 "2" | Out-File -FilePath E:\mytest.txt -Append -Encoding utf8

Get-AzureRmLoadBalancer -Name "testload" -ResourceGroupName "testfun07" | Select-Object InboundNatPools | fl | Out-File -FilePath E:\mytest.txt -Append -Encoding utf8



Set-AzureRmLoadBalancer -LoadBalancer $slb

"3" | Out-File -FilePath E:\mytest.txt -Append -Encoding utf8

Get-AzureRmLoadBalancer -Name "testload" -ResourceGroupName "testfun07" | Select-Object InboundNatPools | fl | Out-File -FilePath E:\mytest.txt -Append -Encoding utf8

票数 0
EN

Stack Overflow用户

发布于 2019-10-18 07:25:13

谢谢你的回复,但最终经过大量的打击和追踪,我找到了答案。

代码语言:javascript
复制
New-AzureRmLoadBalancerInboundNatPoolConfig -Name "natpool3" -Protocol Tcp -FrontendPortRangeStart 50000 -FrontendPortRangeEnd 50119 -BackendPort 3389
$lb= Get-AzureRmLoadBalancer -ResourceGroupName VMSS-RG -Name nbslb
$feip=(Get-AzureRmLoadBalancer -ResourceGroupName VMSS-RG -Name nbslb).FrontendIpConfigurations[0].Id
Add-AzureRmLoadBalancerInboundNatPoolConfig -LoadBalancer $lb -FrontendIpConfigurationId $feip -Name "natpool3" -Protocol Tcp -FrontendPortRangeStart 50000 -FrontendPortRangeEnd 50119 -BackendPort 3389 
Set-AzureRmLoadBalancer -LoadBalancer $lb
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58444208

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档