Configuring a VMkernel port and enable vMotion via command line
search cancel

Configuring a VMkernel port and enable vMotion via command line


Article ID: 324812


Updated On:


VMware vSphere ESXi


VMware recommends using VirtualCenter and Virtual Infrastructure Client (VI Client) for provisioning virtual switches. For more information, see the ESX Administration Guide.

For the purpose of troubleshooting or if you lack a GUI, the command line interface can be utilized to provision virtual switches.

This article provides commands for creating and modifying the VMkernel port.

The VMkernel layer 3 TCP/IP stack handles traffic for the following ESX host services:
  • VMware vMotion
  • iSCSI
  • NFS

Note: VMware recommends using isolated network for iSCSI.


VMware ESXi 4.0.x Installable
VMware ESX 4.1.x
VMware ESXi 4.1.x Installable
VMware ESXi 4.0.x Embedded
VMware ESXi 3.5.x Installable
VMware ESXi 4.1.x Embedded
VMware vSphere ESXi 5.0
VMware ESX Server 3.5.x
VMware vSphere ESXi 5.1
VMware ESX 4.0.x
VMware ESXi 3.5.x Embedded


Create a VMkernelPort on vSwitch via the command line:
esxcfg-vmknic --add --ip=x.x.x.x --netmask=x.x.x.x portgroup
esxcfg-vmknic --enable portgroup
esxcfg-vswitch –l (List vSwitch)
esxcfg-vswitch –a vSwitch1 (Create vSwitch)
esxcfg-vswitch –A “ISCSI” vSwitch1 (Create port group)
esxcfg-vmknic -a -i -n ISCSI (Assign IP)
esxcfg-vmknic –l (List VMkernelPort)
Note: You can have more than one VMkernel on one vSwitch. However, the primary default gateway of the Management VMkernel is used for all the subsequent VMkernel(s).
If you are unable to set the VMkernel gateway because there are no VMkernel interfaces on the same network, see Unable to set VMkernel gateway as there are no VMkernel interfaces on the same network (1002662).
Enable vMotion on vSwitch via the command line:
  • Enable a VirtualNic to be used as the vMotion NIC.
  • Enable and Disable vMotion via SSH connection without VirtualCenter (for ESX/ESXi 3.x use vmware-vim-cmd command)
vim-cmd hostsvc/vmotion/vnic_set [vnic]   
vim-cmd hostsvc/vmotion/vnic_set vmk0  
Disabling vMotion Port: 

vim-cmd hostsvc/vmotion/vnic_unset [vnic]

vim-cmd hostsvc/vmotion/vnic_unset vmk0
Check vSwitch vMotion configuration:
vim-cmd hostsvc/vmotion/netconfig_get

The output appears similar to:

[root@esxserver root]# vim-cmd hostsvc/vmotion/netconfig_get

( {

dynamicType = <unset>,

candidateVnic = ( [

( {

dynamicType = <unset>,

device = "vmk0",

key = "",

portgroup = "ISCSI",

spec = ( {

dynamicType = <unset>,

ip = ( {

dynamicType = <unset>,

dhcp = false,

ipAddress = "xx.xx.xx.xx",

subnetMask = "",


mac = "xx:xx:xx:xx:xx:xx",


port = <unset>,



selectedVnic = <>,


Note: If you see this line, vMotion is enabled.


Additional Information

For translated versions of this article, see: