建立、Delete,或更新承租人 Virtual 網路Create, Delete, or Update Tenant Virtual Networks

適用於:Windows Server(以每年次管道)、Windows Server 2016Applies To: Windows Server (Semi-Annual Channel), Windows Server 2016

若要了解如何建立、delete,以及更新 HYPER-V 網路模擬 Virtual 網路部署軟體定義網路 (SDN) 之後,您可以使用此主題。You can use this topic to learn how to create, delete, and update Hyper-V Network Virtualization Virtual Networks after you deploy Software Defined Networking (SDN).

使用 HYPER-V 網路模擬,您可以找出承租人網路,使每個承租人網路的完全獨立實體不跨連接可能使用除非您設定的工作負載公用存取。Using Hyper-V Network Virtualization, you can isolate tenant networks so that each tenant network is a completely separate entity with no cross-connection possibility unless you configure public access workloads.

建立 tenants Virtual 新的網路,您可以修改現有 Virtual 網路,並如果房客不再需要特定資源,或是承租人不再是您客戶,您可以 delete 承租人 Virtual 網路。You can create new Virtual Networks for tenants, you can modify existing Virtual Networks, and if a tenant no longer needs certain resources, or if the tenant is no longer your customer, you can delete tenant Virtual Networks.

建立新的 Virtual 網路Create a new Virtual Network

當您建立的房客 Virtual 網路時,它放 HYPER-V 主機上的唯一路由網域中。When you create a Virtual Network for a tenant, it is placed within a unique routing domain on the Hyper-V host.

以下是步驟建立新的 Virtual 網路。Following are the steps to create a new Virtual Network.

  1. 找出您要建立的 virtual 子網路的 IP 位址前置詞。Identify the IP address prefixes from which you want to create the virtual subnets.
  2. 找出邏輯提供者網路承租人流量使用的通道。Identify the logical provider network upon which the tenant traffic is tunneled.
  3. 針對每個 IP 首碼所定義步驟 1 中建立至少一 virtual 子網路。Create at least one virtual subnet for each IP Prefix that you defined in step 1.

注意

每個 virtual 網路下方還有至少一個 virtual 子網路。Beneath every virtual network there is at least one virtual subnet. IP 首碼所定義 virtual 子網路,以及參考預先定義的存取控制清單。Virtual Subnets are defined by an IP Prefix and reference a previously defined Access Control List.

(選擇性)完成這些步驟之後,您也可以將先前建立的存取控制清單新增至 virtual 子網路,或新增 tenants 閘道器連接。Optionally, after completing these steps, you can also add the previously created access control lists to the virtual subnets, or add gateway connectivity for tenants.

下表包含兩種虛構 tenants 範例子網路 Id 和前置詞。The following table includes example subnet IDs and prefixes for two fictional tenants. 承租人 Fabrikam 有兩個 virtual 子網路,以 Contoso 承租人有三種 virtual 子網路時。The tenant Fabrikam has two virtual subnets, while the Contoso tenant has three virtual subnets.

承租人名稱Tenant Name 子網路 virtual IDVirtual Subnet ID Virtual 子網路首碼Virtual Subnet Prefix
FabrikamFabrikam 50015001 24.30.1.0/2424.30.1.0/24
FabrikamFabrikam 50025002 24.30.2.0/2024.30.2.0/20
ContosoContoso 60016001 24.30.1.0/2424.30.1.0/24
ContosoContoso 60026002 24.30.2.0/2424.30.2.0/24
ContosoContoso 60036003 24.30.3.0/2424.30.3.0/24

下列範例指令碼使用 Windows PowerShell 命令匯出從NetworkController模組建立 Contoso virtual 網路和一個子網路:The following example script uses Windows PowerShell commands exported from the NetworkController module to create Contoso's virtual network and one subnet:

import-module networkcontroller  
$URI = "https://ncrest.contoso.local"  

#Find the HNV Provider Logical Network  

$logicalnetworks = Get-NetworkControllerLogicalNetwork -ConnectionUri $uri  
foreach ($ln in $logicalnetworks) {  
   if ($ln.Properties.NetworkVirtualizationEnabled -eq "True") {  
      $HNVProviderLogicalNetwork = $ln  
   }  
}   

#Find the Access Control List to user per virtual subnet  

$acllist = Get-NetworkControllerAccessControlList -ConnectionUri $uri -ResourceId "AllowAll"  

#Create the Virtual Subnet  

$vsubnet = new-object Microsoft.Windows.NetworkController.VirtualSubnet  
$vsubnet.ResourceId = "Contoso_WebTier"  
$vsubnet.Properties = new-object Microsoft.Windows.NetworkController.VirtualSubnetProperties  
$vsubnet.Properties.AccessControlList = $acllist  
$vsubnet.Properties.AddressPrefix = "24.30.1.0/24"  

#Create the Virtual Network  

$vnetproperties = new-object Microsoft.Windows.NetworkController.VirtualNetworkProperties  
$vnetproperties.AddressSpace = new-object Microsoft.Windows.NetworkController.AddressSpace  
$vnetproperties.AddressSpace.AddressPrefixes = @("24.30.1.0/24")  
$vnetproperties.LogicalNetwork = $HNVProviderLogicalNetwork  
$vnetproperties.Subnets = @($vsubnet)  
New-NetworkControllerVirtualNetwork -ResourceId "Contoso_VNet1" -ConnectionUri $uri -Properties $vnetproperties  

修改現有 Virtual 網路Modify an existing Virtual Network

您可以使用 Windows PowerShell 來更新現有虛擬子網路。You can use Windows PowerShell to update an existing Virtual subnet or network.

已更新的資源當您執行以下的範例指令碼時,只是要使用相同的資源收到 Network ControllerWhen you run the following example script, the updated resources are simply PUT to Network Controller with the same resource ID. 如果您承租人 Contoso 想要新增新 virtual 子網路 (24.30.2.0 月 24)他們 virtual 的網路,您或 Contoso 系統管理員可以使用下列的指令碼。If your tenant Contoso wants to add a new virtual subnet (24.30.2.0/24) to their virtual network, either you or the Contoso Administrator can use the following script.

$acllist = Get-NetworkControllerAccessControlList -ConnectionUri $uri -ResourceId "AllowAll"  

$vnet = Get-NetworkControllerVirtualNetwork -ResourceId "Contoso_VNet1" -ConnectionUri $uri  

$vnet.properties.AddressSpace.AddressPrefixes += "24.30.2.0/24"  

$vsubnet = new-object Microsoft.Windows.NetworkController.VirtualSubnet  
$vsubnet.ResourceId = "Contoso_DBTier"  
$vsubnet.Properties = new-object Microsoft.Windows.NetworkController.VirtualSubnetProperties  
$vsubnet.Properties.AccessControlList = $acllist  
$vsubnet.Properties.AddressPrefix = "24.30.2.0/24"  

$vnet.properties.Subnets += $vsubnet  

New-NetworkControllerVirtualNetwork -ResourceId "Contoso_VNet1" -ConnectionUri $uri -properties $vnet.properties  

Delete Virtual 網路Delete a Virtual Network

您可以使用 Windows PowerShell 來 delete Virtual 網路。You can use Windows PowerShell to delete a Virtual Network.

Windows PowerShell 下例 HTTP delete 發出的資源 ID uri 移除房客 Virtual 網路The following Windows PowerShell example deletes a tenant Virtual Network by issuing an HTTP delete to the URI of the Resource ID.

Remove-NetworkControllerVirtualNetwork -ResourceId "Contoso_Vnet1" -ConnectionUri $uri