偶然间用到的一个外国牛人的脚本。通过该脚本可以获取ESXI主机虚拟交换机中的MAC地址表。
# Author: William Lam
# Website: www.virtuallyghetto.com
# Product: VMware ESXi
# Description: Query MACs on internal vSwitch
# Reference: http://www.virtuallyghetto.com/2011/05/how-to-query-for-macs-on-internal.html
if [[ $# -ne 1 ]] && [[ $# -ne 4 ]]; then
echo -e "Usage: $0 -l -v [vSWITCH] -p [PORT]\n"
echo " -l List all ports of vSwitch(s)"
echo " -v vSwitch to query"
echo " -p Port to query on vSwitch"
echo -e "\n\t$0 -l"
echo -e "\t$0 -v vSwitch0 -p 1234\n"
exit 0
fi
if [ ! -e /sbin/vsish ]; then
echo "Script is only supported running on an ESXi host as vsish is not available by default on ESX"
exit 1
fi
VSISH_VSWITCH_PATH=/net/portsets
if [ $# -eq 1 ]; then