Roughly a half year ago we came across a situation in which an VMware NSX environment was having problems consistingly applying routing and firewall rules. After some troubleshooting it appeared to be a problem with duplicate VTEP (VXLAN Tunnel Enpoint) addresses on the vSphere hosts. We fixed the problem, but we wanted to have some sort of periodic check to alert us, should this occur again.

As with most of these things this periodic check was put on the backlog, and only recently we got around to finding a solution. We choose to use a Powershell script that we would run as a scheduled job at the start of every day. At first we had a look at PowerNSX, since this module already offers a great deal of functions. Unfortunately we did not find a function within PowerNSX that could retreive VTEP addresses.

However PowerNSX did give us the insight in how we could connect with NSX using Powershell. Basically it uses the NSX API, meaning we could also retreive any content unlocked by the API. Knowing this we first use a request to retreive the available IP pools and select the pool in question. With that pool selected we do another request to get all the IP addresses that are in use. And finally we created a loop that would check if any of the addresses had a duplicate.

Powershell script

The script only contains the part used to retreive the IP addresses and check on duplicates. Besides the write-host lines there was also a function for sending an text message to phones. But you could script any type of alert you would like for your own environment.

Hopefully this article can give you some ideas on how to use Powershell and the NSX API. I think the options are legion 🙂