共用方式為


Add-NetNatStaticMapping

Add-NetNatStaticMapping

Adds a static mapping to a NAT instance.

語法

Parameter Set: cim:CreateInstance0
Add-NetNatStaticMapping [-NatName] <String> -ExternalIPAddress <String> -ExternalPort <UInt16> -InternalIPAddress <String> -Protocol <Protocol> [-AsJob] [-CimSession <CimSession[]> ] [-InternalPort <UInt16> ] [-InternalRoutingDomainId <String> ] [-RemoteExternalIPAddressPrefix <String> ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

詳細描述

The Add-NetNatStaticMapping cmdlet adds a static mapping to a network address translation (NAT) instance. A static mapping enables an incoming connection from an external network to access a host on an internal network through the NAT.

You can use NAT to share a connection to the public Internet through a single interface with a single public IP address. The computers on the private network use private, non-routable addresses. NAT maps the private addresses to the public address.

參數

-AsJob

別名

必要?

false

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-CimSession<CimSession[]>

在遠端工作階段或遠端電腦上執行 Cmdlet。輸入電腦名稱或工作階段物件,例如 New-CimSessionGet-CimSession Cmdlet 的輸出。預設為本機電腦上的目前工作階段。

別名

Session

必要?

false

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-ExternalIPAddress<String>

Specifies the external IP address to which an incoming connection is addressed. This parameter specifies the destination IP address in the incoming packet

別名

必要?

true

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-ExternalPort<UInt16>

Specifies the external port to which an incoming connection is sent. This parameter specifies the destination port in the incoming TCP or UDP packets.

別名

必要?

true

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-InternalIPAddress<String>

Specifies the IP address to which the packets from a remote machine in the external network are addressed.

別名

必要?

true

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-InternalPort<UInt16>

Specifies the internal port to which the packets from a remote machine in the external network are sent. If you do not specify this parameter, NAT uses the port that you specify for the ExternalPort parameter for the internal port.

別名

必要?

false

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-InternalRoutingDomainId<String>

Specifies the GUID of the routing domain of the internal interface.

別名

必要?

false

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-NatName<String>

Specifies the name of the NAT instance.

別名

必要?

true

位置?

1

預設值

接受管線輸入?

false

接受萬用字元?

false

-Protocol<Protocol>

Specifies the network protocol of the client computer in the internal network. 此參數接受的值包括:

-- TCP
-- UDP

別名

必要?

true

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-RemoteExternalIPAddressPrefix<String>

Specifies the IP address prefix of the remote computer on the external network.

別名

必要?

false

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-ThrottleLimit<Int32>

指定為執行此 Cmdlet 可建立的最大同時作業數。如果省略這個參數或輸入 0 的值,則 Windows PowerShell® 會根據在電腦上執行的 CIM Cmdlet 數目,計算 Cmdlet 的最佳節流限制。節流限制僅適用於目前 Cmdlet,不適用於工作階段或電腦。

別名

必要?

false

位置?

named

預設值

接受管線輸入?

false

接受萬用字元?

false

-Confirm

執行 Cmdlet 之前先提示您確認。

必要?

false

位置?

named

預設值

false

接受管線輸入?

false

接受萬用字元?

false

-WhatIf

顯示執行 Cmdlet 後會發生的情況。未執行 Cmdlet。

必要?

false

位置?

named

預設值

false

接受管線輸入?

false

接受萬用字元?

false

<CommonParameters>

此 Cmdlet 支援一般參數:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 與 -OutVariable。如需詳細資訊,請參閱 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。

輸入

輸入類型是您可以使用管線處理方式傳遞給 Cmdlet 的物件類型。

  • None

輸出

輸出類型是 Cmdlet 所發出的物件類型。

  • Microsoft.Management.Infrastructure.CimInstance#ROOT/StandardCimv2/MSFT_NetNatStaticMapping

範例

Example 1: Add a static mapping to a NAT instance

This command adds a static mapping to a NAT instance. The command specifies that NAT maps the external IP address to the internal IP address 192.0.02.179. The command specifies that the NAT maps the destination port 80 of the Internet resource to the source application port 8080. The command specifies that the tenant compartment that has the ID TSQATenant contains the internal address and internal port. This example uses the placeholder a.b.c.0/24 to represent a public Internet address prefix.

PS C:\> Add-NetNatStaticMapping -ExternalIPAddress "a.b.c.0/24" -ExternalPort 80 -InternalIPAddress "192.0.02.179" -InternalPort 8080 -InternalRoutingDomainId "{12345678-0000-0000-0000-123456789012}" 

相關主題

Get-NetNatStaticMapping

Remove-NetNatStaticMapping