Here is another way in you can enable the management traffic type on a VMkernel interface in ESXi without having to resort to using the vSphere API, this especially useful when automating a kickstart installation.
When you enable a specific vmkX interface (esxcfg-vmknic -l) to allow for the management traffic type, there is an entry that is made in the /etc/vmware/hostd/hostsvc.xml file. The specific interface is denoted by a unique nic id which starts off at 0000 and is incremented by one for additional VMkernel interfaces that are added.
If you add a second VMkernel interface called vmk1 and you wanted to also enable it for management traffic, the file would look like the following:
For the changes to take effect, you will need to restart hostd agent by running /etc/init.d/hostd restart. You will also need refresh the network sub-system by using vim-cmd hostsvc/net/refresh which will refresh the vSphere Client view else you will have to do it manually before you can see the update.
This is probably overkill, but I decided to write a simple script in which you can pass the VMkernel interface name and the script will update hostsvc.xml file with the proper nic id/etc. Here is an example for enabling management traffic for vmk1:
Download: enableMgmt.sh
If you would like to integrate this into your ESXi kickstart, you can easily do so based on the number of VMkernel interfaces you will be creating during the installation. You can add the following into your %post section which uses a here document to overwrite the existing hostsvc.xml with the expected VMkernel interfaces that should have the management traffic type enabled.
HOSTSVC_FILE=/etc/vmware/hostd/hostsvc.xml
cat > ${HOSTSVC_FILE} << __CREATE_HOST_SVC__
vmk0
vmk1
vmk2
normal
on
on
on
__CREATE_HOST_SVC__
This is a cleaner alternative than using python and connecting to the vSphere API locally on an ESXi host which is described in my blog article Automating ESXi 4.1 Kickstart Tips & Tricks Tip #7
macfaden says
Should be:
For the changes to take effect
Either
you will need to restart hostd agent by running /etc/init.d/hostd restart
or
refresh the network sub-system by using vim-cmd hostsvc/net/refresh
Doing both is overkill.
LaClair says
With ESXi 5 I took a slightly different approach.
since I'm installing over http I just put a hostsvc.xml file out on the webserver with vmk0 and vmk1 in there (as listed above, thanks for pointing me in the right direction)
From there all I did was
wget http://webserver/hostsvc.xml -O /tmp/hostsvc.xml
cp /tmp/hostsvc.xml /etc/vmware/hostd/hostsvc.xml
/etc/init.d/hostd restart
vim-cmd hostsvc/net/refresh
I do have sleep commands in between each line, I'm sure it's overkill but I was just trying to rule out any variables.
On the contrary to what MacFaden stated above, in my findings if I did the hostsvc refresh before restarting hostd then the copied file would revert back to normal. Granted my approach was a little different than the one blogged here but I'm sure the behavior has to be similar.
Now time for the burning question... why isn't a simple task like enabling management traffic a esxcli or vim-cmd command?
Anonymous says
Hi
i know this post is old, but i just wanted to add that it actually is possible via esxcli.
like so:
esxcli network ip interface tag add -i vmk1 -t Management