Scan IP addresses through Esxi VMkernal Interfaces

Unlike the ESXi management interface, VMK interfaces used for vMotion can typically only be pinged within the same subnet, as they are not assigned a gateway IP address. Below is a shell script you can utilize directly on the ESXi host without the need for third-party IP ping tools.

Here is the sample script, we assume to ping from 192.168.1.10 to 192.168.1.100.

You can download the above script from here.

After copying the script into esxi host, make sure you set the file to be executable.

chmod 744 ping_vmk_ips.sh

after which your can run the script with

sh ping_vmk_ips.sh

The description of the script parameters are:

START_IP – the fourth octect of the starting IP address. e.g; if the starting IP is 192.168.1.10 then it should be 10.

END_IP – the fourth octect of the starting IP address. e.g; if the starting IP is 192.168.1.100 then it should be 100.

BASE_IP – the first three octets of the IP address. For the above example, it should be 192.168.1

NetworkStackName – The TCP/IP stack name which is associated with desired VMkernel adapters. Here, since the vmk1 (used for vMotion) resides in vSwitch1, the associated network stack is “vMotion”.

If you’re unsure about the location of the VMkernel adapters within the network stacks, use the following command:

esxcli network ip interface list

If you want to list the all vmk and IP addresses, use the following command.

esxcli network ip interface ipv4 get
This entry was posted in Linux, Shell Scripts, VMware. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *