Options to find a MAC Address in VMware Environment.

In one of my ESXi host we have found the alert mentioning the NFS IP Conflict and it points the specific  MAC address as the owner . I was looking to find the Host\IP which is causing the conflict and found some various options to find the results from both the ESXi \VM level and hope it will be useful to share the information..

Method 1 – Simple commands

First by using the below command and it will search all the VMFS datastores and give the result with the appropriate VMX which is very useful to find the MAC of any VM vnic.( Below command is from the Reference Link )

find /vmfs/volumes | grep .vmx$ | while read i; do \ grep -i “00:50:**:**:**:**” “$i” && echo “$i”; done

mac

If it couldn’t get the result then it will give the empty message..

Other Options :

Display the list of known network neighbors in the ARP and ND cache for all VMkernel network interfaces using one of the command

Next if we want to list the Mac of the VMKNIC then we can use the below command

esxcli network ip neighbor list 

mac1

By using the VMware debug mode we can try the below command

vmware -l

To Determine the MAC address of an ESX Hosts administration interface.

# ifconfig |grep -i hw

The output appears similar to:

vswif0    Link encap:Ethernet  HWaddr 00:50:56:41:5A:59

The MAC address is found in the first line after HWaddr.  In this example, the MAC address is 00:50:56:41:5a:59.

Note:  The ESX host uses self-generated addresses starting with 00:50:56 (as opposed to the burned-in address of the interface itself).

Alternatively, review the outputted information and MAC addresses from the command esxcfg-nics -l.

Method -2 – DHCP Server

Another way to find the Mac address is from the DHCP Server , Go to the Scope – Address Lease , It will list all the IPs with the Mac address but it will help only for the DHCP IPs and not for the static address .

Method-3 – ARP 

Next step is to try the ARP command which will give the list of recently resolved IP addresses to MAC address mapping from the ARP cache.

To populate the ARP table, ping a broadcast IP address to get a reply back from all hosts listening on the same subnet.

For example :ping 10.10.10.255

To list the ARP table, run the command:

arp -a

Have a try on both from the ESX and the Vcenter so that we can get more chances to find the IP..

Method 4 – find the manufacturer.

If you suspect the MAC is from any hardware like printer then we can try the below link to find the manufacturer.

http://curreedy.com/stu/nic/

Method – 5  How to find the MAC of the ESXi servers using the PowerCLI.

Pls see the below reference link for the info of the script and I just copied the main content of the script here..

1
2
3
4
Get-VMHost | `
  Get-VMHostNetworkAdapter | `
  Where-Object {$_.Mac -eq "00:50:56:78:98:a2"} | `
  Format-List -Property *

The Get-VmMacAddress function use the function to find the MAC of the VM using the powerCLI.

Method -6Free Tools

Lot of free tools are available in the internet like IP Scanner but the tool have to scan the entire network ..

 

Reference:

http://rvdnieuwendijk.com/2011/07/17/how-to-use-vmware-vsphere-powercli-to-find-an-esxesxi-server-by-mac-address/

http://rvdnieuwendijk.com/2011/09/12/how-to-use-vmware-vsphere-powercli-to-find-the-mac-addresses-of-a-virtual-machine/

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1008184

http://backdrift.org/finding-a-mac-address-in-vmware-esx

http://thebackroomtech.com/2010/08/22/determine-ip-address-from-a-mac-address/

Advertisement
This entry was posted in VMware and tagged , , , , . Bookmark the permalink.

3 Responses to Options to find a MAC Address in VMware Environment.

  1. Emile Mercier says:

    [root@VMHOST02:/sys] cat findMac

    #!/bin/sh
    nope(){
    echo provide a valid mac address.
    exit 1
    }

    echo $@ | egrep -i ‘^[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}$’ || nope
    ss=$@
    ss=`echo $ss|sed ‘s/-/:/g’`
    ss=`echo $ss|sed ‘s/://g’`
    ss=`echo $ss|sed ‘s/../&:/g;s/:$//’`
    echo $ss
    exit 1
    while read line; do
    grep -i “$ss” “$line” && echo $line | tee /tmp/output.out
    done << EOF
    `find /vmfs/volumes | grep .vmx$`
    EOF

    Like

  2. Emile Mercier says:

    oops. This is the one:

    [root@VMHOST02:/sys] cat findMac
    #!/bin/sh
    nope(){
    echo provide a valid mac address.
    exit 1
    }

    echo $@ | egrep -i ‘^[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}$’ || nope
    ss=$@
    ss=`echo $ss|sed ‘s/-/:/g’`
    ss=`echo $ss|sed ‘s/://g’`
    ss=`echo $ss|sed ‘s/../&:/g;s/:$//’`

    while read line; do
    grep -i “$@” “$line” && echo $line | tee /tmp/output.out
    done << EOF
    `find /vmfs/volumes | grep .vmx$`
    EOF

    Like

  3. Emile Mercier says:

    oh lord, another mis-paste. Just shoot me. please replace the $@ with $ss in the final while read loop. You get it.

    Ok, here is the final frickin’ paste:

    [root@VMHOST02:/sys] cat findMac
    #!/bin/sh
    nope(){
    echo provide a valid mac address.
    exit 1
    }

    echo $@ | egrep -i ‘^[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}[:-]?[0-9a-f]{2}$’ || nope
    ss=$@
    ss=`echo $ss|sed ‘s/-/:/g’`
    ss=`echo $ss|sed ‘s/://g’`
    ss=`echo $ss|sed ‘s/../&:/g;s/:$//’`

    while read line; do
    grep -i “$ss” “$line” && echo $line | tee /tmp/output.out
    done << EOF
    `find /vmfs/volumes | grep .vmx$`
    EOF

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s