VMware

This Question is Not Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
0 Replies Last post: Feb 11, 2009 2:36 PM by c_shanklin  

Reconfigure virtual switches to use IP-based load balancing. posted: Feb 11, 2009 4:12 PM

Click to view c_shanklin's profile Master 754 posts since
Dec 3, 2007
Hi,

Someone asked today how to reconfigure all virtual switches to use IP-based load balancing. I decided to post the answer here, hope you find it useful.

# This script will reconfigure all virtual switches with more than 1 NIC to use
# IP-based load balancing.
# NOTE: The script will reconfigure *ALL* virtual switches on *ALL* hosts.
# Change the Get-VMHost statement if that's not what you want.
Get-VMHost | Get-VMHostNetwork | foreach {
	$networkView = $_ | Get-View
	$switches = $networkView.NetworkInfo.Vswitch | Where { $_.Pnic.length -gt 1 }
	foreach ($switch in $switches) {
		$spec = $switch.spec
		$spec.policy.nicTeaming.policy = "loadbalance_ip"
		# Other values are loadbalance_srcmac, loadbalance_srcid (The default), failover_explicit
		$networkView.UpdateVirtualSwitch($switch.Name, $spec)
	}
}

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities