* Home :: Get a random password :: Get a multi-word password :: What is my IP? (v4 | v6)
* My projects

How to enable MAC learning on VMWare distributed Virtual Switches

Tags: vmware, dvs, howto

MAC learning is required in certain situations such as when running nested environments (ESXi on ESXi etc).

This is unfortunately not possible from the web UI, so the API needs to be used.

I won't be calling the API directly in this document, but I'll use scripts written by others to do so.

The procedure is quite simple, takes just a few minutes.

1. Assuming you are on Linux (CentOS7) please install Microsoft's Powershell

curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo

yum install -y powershell

2. Download vmware-scripts from Github

yum -y install git && git clone https://github.com/lamw/vmware-scripts.git

cd vmware-scripts/powershell

3. Launch Powershell, install VMWare's PowerCLI (Powershell addon) and load the MAC learning script, just as you would in bash


Install-Module -Name VMware.PowerCLI

. ./MacLearn.ps1

4. Disable Powershell's SSL validity checking (as you most likely have a self-signed one) and connect to vCenter (using your own user/pass combination)

Set-PowerCLIConfiguration -InvalidCertificateAction:Ignore

Connect-VIServer -Server -User Admin -Password Pass

5. First let's get the current values and then if necessary let's set up MAC learning.

Get-MacLearn -DVPortgroupName @('pg.1337.200.1-dvSwitch1')

DVPortgroup            : virtual.switch.1337.200.1-dvSwitch1
MacLearning            : False
NewAllowPromiscuous    : False
NewForgedTransmits     : False
NewMacChanges          : False
Limit                  :
LimitPolicy            :
LegacyAllowPromiscuous : False
LegacyForgedTransmits  : False
LegacyMacChanges       : False

Ok, so MAC learning is disabled. Let's enable it.

Set-MacLearn -DVPortgroupName @("virtual.switch.1337.200.1-dvSwitch1") -EnableMacLearn $true -EnablePromiscuous $false -EnableForgedTransmit $true -EnableMacChange $false


(c)The Nux(tm) ;-)