New-AzVpnGatewayNatRule
在可以與 VpnSiteLinkConnection 相關聯的 VpnGateway 上建立 NAT 規則。
語法
New-AzVpnGatewayNatRule
-ResourceGroupName <String>
-ParentResourceName <String>
-Name <String>
[-Type <String>]
[-Mode <String>]
-InternalMapping <String[]>
-ExternalMapping <String[]>
[-InternalPortRange <String[]>]
[-ExternalPortRange <String[]>]
[-IpConfigurationId <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzVpnGatewayNatRule
-ParentObject <PSVpnGateway>
-Name <String>
[-Type <String>]
[-Mode <String>]
-InternalMapping <String[]>
-ExternalMapping <String[]>
[-InternalPortRange <String[]>]
[-ExternalPortRange <String[]>]
[-IpConfigurationId <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzVpnGatewayNatRule
-ParentResourceId <String>
-Name <String>
[-Type <String>]
[-Mode <String>]
-InternalMapping <String[]>
-ExternalMapping <String[]>
[-InternalPortRange <String[]>]
[-ExternalPortRange <String[]>]
[-IpConfigurationId <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
在可與 VpnGateway 建立關聯的 VpnGateway NAT 規則。
範例
範例 1
New-AzResourceGroup -Location "West US" -Name "testRG"
$virtualWan = New-AzVirtualWan -ResourceGroupName testRG -Name myVirtualWAN -Location "West US"
$virtualHub = New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.0.1/24"
New-AzVpnGateway -ResourceGroupName "testRG" -Name "testvpngw" -VirtualHubId $virtualHub.Id -VpnGatewayScaleUnit 2
$vpnGateway = Get-AzVpnGateway -ResourceGroupName "testRG" -Name "testvpngw"
New-AzVpnGatewayNatRule -ResourceGroupName $vpnGateway.ResourceGroupName -ParentResourceName $vpnGateway.Name -Name "testNatRule" -Type Static -Mode EgressSnat -InternalMapping "10.0.0.1/26" -ExternalMapping "192.168.0.0/26" -InternalPortRange "100-100" -ExternalPortRange "200-200"
Type : Static
Mode : EgressSnat
VpnConnectionProtocolType : IKEv2
InternalMappings : 10.0.0.1/26
ExternalMappings : 192.168.0.0/26
InternalPortRange : 100-100
ExternalPortRange : 200-200
IpConfigurationId :
IngressVpnSiteLinkConnections : [Microsoft.Azure.Commands.Network.Models.PSResourceId]
EgressVpnSiteLinkConnections : [Microsoft.Azure.Commands.Network.Models.PSResourceId]
ProvisioningState : Provisioned
Name : ps9709
Etag : W/"4580a2e2-2fab-4cff-88eb-92013a76b5a8"
Id : /subscriptions/{subscriptionId}/resourceGroups/testRg/providers/Microsoft.Network/vpnGateways/testvpngw/natRules/testNatRule
上述會建立資源群組、虛擬 WAN、虛擬網路、虛擬中樞。 然後,我們將在該虛擬中樞下建立 VpnGateway。 然後,使用此命令:New-AzVpnGatewayNatRule,NAT 規則可以建立並與建立的 VpnGateway 建立關聯。
參數
-AsJob
在背景執行 Cmdlet
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
類型: | SwitchParameter |
別名: | cf |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-DefaultProfile
用於與 Azure 通訊的認證、帳戶、租用戶和訂用帳戶。
類型: | IAzureContextContainer |
別名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-ExternalMapping
NAT 的私人IP位址子網外部對應清單
類型: | String[] |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-ExternalPortRange
NAT 子網的外部埠範圍對應清單
類型: | String[] |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-InternalMapping
NAT 的私人IP位址子網內部對應清單
類型: | String[] |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-InternalPortRange
NAT 子網的內部埠範圍對應清單
類型: | String[] |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-IpConfigurationId
此 NAT 規則適用的IP組態標識碼
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Mode
VPN NAT 的來源 NAT 方向
類型: | String |
接受的值: | EgressSnat, IngressSnat |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Name
資源名稱。
類型: | String |
別名: | ResourceName, VpnGatewayNatRuleName |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-ParentObject
此 NAT 規則的父 VpnGateway。
類型: | PSVpnGateway |
別名: | ParentVpnGateway, VpnGateway |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-ParentResourceId
此 NAT 規則之父 VpnGateway 的資源識別碼。
類型: | String |
別名: | ParentVpnGatewayId, VpnGatewayId |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-ParentResourceName
資源組名。
類型: | String |
別名: | ParentVpnGatewayName, VpnGatewayName |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-ResourceGroupName
資源組名。
類型: | String |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-Type
VPN NAT 的 NAT 規則類型
類型: | String |
接受的值: | Static, Dynamic |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 Cmdlet 未執行。
類型: | SwitchParameter |
別名: | wi |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |