Home > Blogs > VMware PowerCLI Blog

Enhanced VMkernel Networking Configuration in vSphere PowerCLI 4.1

You can now use PowerCLI to manipulate VMKernel networking and routing. There is a new functionality that supports setting a default gateway for VMKernel networks as well as creating, removing and updating of host routes.

Here is an example illustrating how to set a default gateway for VMKernel. All you need is to have a configured VMKernel adapter in the same subnet as the gateway you want to set to default. Let’s say you want to set a default gateway First you should check which VMKernel adapter to use:

Get-VMHostNetworkAdapter  -VMKernel | select ‘Ip’, ‘SubnetMask’, ‘DeviceName’

IP     SubnetMask    DeviceName

——————-    ———- ———-     vmk1     vmk0


You should select the vmk1 network adapter which is in the same subnet as the default gateway:

# Example 1: Setting the default VMKernel gateway

$net = Get-VMHostNetwork

$net | Set-VMHostNetwork -VMKernelGateway ‘’ -VMKernelGatewayDevice ‘vmk1’


The next example illustrates creating a VMKernel route that splits the VMKernel traffic. Looking at the previous example you can see that the vmk0 device is in a subnet with a host IP range ( – Below there is a sample code that splits the VMKernel traffic for the ( – and ( – subnets to different gateways:

# Example 2: Creating host routes

New-VMHostRoute -Destination ‘’ -PrefixLength 24 -Gateway ‘’

New-VMHostRoute -Destination ‘’ -PrefixLength 24 -Gateway ‘’


You can remove these routes using the Get-VMHostRoute and Remove-VMHostRoute cmdlets:

#Example 3: Removing host routes

Get-VMHostRoute  | where { $_.Destination -eq “”} | Remove-VMHostRoute

Get-VMHostRoute  | where { $_.Destination -eq “”} | Remove-VMHostRoute


For more details about host routing with PowerCLI 4.1, see the cmdlets help and the online documentation.


Gospodin Gochkov

Leave a Reply

Your email address will not be published. Required fields are marked *