Create and Configure a Logical Network and IP Address Pool (Script)

 

Updated: May 13, 2016

Applies To: System Center 2012 R2 Virtual Machine Manager, System Center 2012 - Virtual Machine Manager

Logical networks enable network administrators to model the network based on recognizable categories that align to business needs by grouping together subnets and VLANs. After you create a new logical network, use the logical network definition, also called a network site, to assign IP subnets and VLANs to the logical network.

You can create a static IP address pool and associate it with one or more host groups. After you have created a static IP address pool, you can add DNS servers to it by using the Set-SCStaticIPAddressPool cmdlet.

For more information about configuring networking in System Center 2012 – Virtual Machine Manager, see Configuring Networking in VMM.

Disclaimer

The following script creates and configures a logical network and a static IP address pool. The script assumes that you have already created a host group named Seattle.

  
# Description:   This script creates a logical network and then creates a logical   
#                network definition that it applies it to the logical network.  
#                The script then creates a static IP address pool, associates   
#                the pool with a host group, and adds DNS servers.   
  
# Create a logical network.  
$LogicalNetwork = New-SCLogicalNetwork -Name "FrontEnd"  
  
# Create a logical network definition and associate it with the new logical network.  
$HostGroup = Get-SCVMHostGroup | where { $_.Path -eq "All Hosts\Seattle" }  
$SubnetVLAN = New-SCSubnetVLAN -Subnet "10.0.0.1/24" -VLAN 25  
$LogNetDef = New-SCLogicalNetworkDefinition -Name "Logical Network Definition for Seattle" -LogicalNetwork $LogicalNetwork -VMHostGroup $HostGroup -SubnetVLAN $SubnetVLAN  
  
# Create a static IP address pool and associate it with a host group.  
$HostGroup = Get-SCVMHostGroup | where { $_.Path -eq "All Hosts\New York\Production" }  
$DefaultGateway = New-SCDefaultGateway -IPAddress "10.0.0.1" -Metric 10  
$IPPool = New-SCStaticIPAddressPool -LogicalNetworkDefinition $LogNetDef -Name "Production IP Address Pool" -Description "This IP address pool is for production use in Seattle." -Subnet "10.0.0.0/24" -IPAddressRangeStart "10.0.0.10" -IPAddressRangeEnd "10.0.0.99" -IPAddressReservedSet "10.0.0.25-10.0.0.35, 10.0.0.38" -VIPAddressSet "10.0.0.95-10.0.0.99" -DNSSuffix "domain.contoso.com" -DNSSearchSuffix domain1.contoso.com, domain2.contoso.com -DNSServer "10.0.0.1", "10.0.0.2" -WINSServer "10.0.0.1", "10.0.0.2" -DefaultGateway $DefaultGateway -EnableNetBIOS $True  
  
# Add DNS servers to the static IP address pool.  
$DNSServerIPAddress = $IPPool.DNSServers  
$DNSServerIPAddress += "10.0.0.5"  
Set-SCStaticIPAddressPool -StaticIPAddressPool $IPPool -DNSServer $DNSServerIPAddress  
  

See Also

New-SCLogicalNetwork
New-SCLogicalNetworkDefinition
New-SCStaticIPAddressPool
Set-SCStaticIPAddressPool