Search the VMware Knowledge Base (KB)
View by Article ID

Configuring a VMkernel port and enable vMotion via command line (1006989)

  • 27 Ratings


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.


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:



Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.


  • 27 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.

What can we do to improve this information? (4000 or fewer characters)

Please enter the Captcha code before clicking Submit.
  • 27 Ratings