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

Configuring a VMkernel port and enable vMotion via command line

book

Article ID: 324812

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

VMware recommends using th VC Client  for provisioning virtual switches. For more information, see the Manage Virtual Switches in the VMware Host Client

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.



Environment

VMware vSphere ESXi 

Resolution

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
 
Example:
 
esxcfg-vswitch –l (List vSwitch)
esxcfg-vswitch –a vSwitch1 (Create vSwitch)
esxcfg-vswitch –A “ISCSI” vSwitch1 (Create port group)
esxcfg-vmknic -a -i 10.10.10.33 -n 255.255.255.0 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 ESX/ESXi power on error: Unable to set VMkernel gateway as there are no VMkernel interfaces on the same network.
 
 
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

(vim.host.VMotionSystem.NetConfig) {

dynamicType = <unset>,

candidateVnic = (vim.host.VirtualNic) [

(vim.host.VirtualNic) {

dynamicType = <unset>,

device = "vmk0",

key = "key-vim.host.VirtualNic-vmk0",

portgroup = "ISCSI",

spec = (vim.host.VirtualNic.Specification) {

dynamicType = <unset>,

ip = (vim.host.IpConfig) {

dynamicType = <unset>,

dhcp = false,

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

subnetMask = "255.255.255.0",

},

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

},

port = <unset>,

}

],

selectedVnic = <vim.host.VirtualNic:key-vim.host.VirtualNic-vmk0>,

}

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

<vim.host.VirtualNic:key-vim.host.VirtualNic-vmk0>