Upravit

Sdílet prostřednictvím


New-AzVirtualNetworkGatewayNatRule

Creates the virtual network gateway natRule object.

Syntax

New-AzVirtualNetworkGatewayNatRule
   -Name <String>
   -Type <String>
   -Mode <String>
   -InternalMapping <String[]>
   -ExternalMapping <String[]>
   [-InternalPortRange <String[]>]
   [-ExternalPortRange <String[]>]
   [-IpConfigurationId <String>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

New-AzVirtualNetworkGatewayNatRule cmdlet creates a PSVirtualNetworkGatewayNatRule object which represents natRules property in your virtual network gateway.

Examples

Example 1

$gateway = Get-AzVirtualNetworkGateway -ResourceGroupName myRg -Name gw1
$natRule = New-AzVirtualNetworkGatewayNatRule -Name "natRule1" -Type "Static" -Mode "IngressSnat" -InternalMapping @("25.0.0.0/16") -ExternalMapping @("30.0.0.0/16") -InternalPortRange @("100-100") -ExternalPortRange @("200-200")
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $gateway -NatRule $natRule

The first command gets a virtual network gateway named gw1 that belongs to resource group myRg and stores it to the variable named $gateway The second command creates a new PSVirtualNetworkGatewayNatRuleirtual object. The third command updates the virtual network gateway gw1 with the with newly added natRule.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ExternalMapping

The list of private IP address subnet external mappings for NAT

Type:String[]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ExternalPortRange

The list of external port range mappings for NAT subnets

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InternalMapping

The list of private IP address subnet internal mappings for NAT

Type:String[]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-InternalPortRange

The list of internal port range mappings for NAT subnets

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-IpConfigurationId

The IP Configuration ID this NAT rule applies to

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Mode

The Source NAT direction of a VPN NAT

Type:String
Accepted values:EgressSnat, IngressSnat
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Name

The resource name.

Type:String
Aliases:ResourceName, VirtualNetworkGatewayNatRuleName
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Type

The type of NAT rule for VPN NAT

Type:String
Accepted values:Static, Dynamic
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

PSVirtualNetworkGatewayNatRule