How to discover the MAC address of machines in a network?

37,381

Solution 1

You will have to access the information available on your managed switches. If you have an unmanaged network, I don't see a way to do that.

This is assuming the target computers are capable of Wake-on-LAN (WoL). In this case, a link to the server is established (look for the flashy link LED), and the network card is listening to WoL broadcasts. AFAIK, the card does not answer to anything in this state. If there isn't any WoL, the card most probably is off (no link LED), and it won't work at all.

Solution 2

If the machines are not powered up, this is impossible.

If they are powered up, I would guess this is impossible as well, as you need a minimal network stack to at least answer things like ARP queries etc, which isn't working without an OS installed.

What might work (I don't know and can't test right now) is that the NIC and the switch communicate when the NIC is plugged in or powered up and the switch learns the MAC address this way. If this is the case you would need a manageable switch and query it for connected mac addresses.

Solution 3

You can use Nmap to do a very quick ARP scan using the following syntax.

nmap -sn -PR -oX nmap.xml 192.168.1.0/24

This uses ARP ping (only ARP requests, no ICMP, UDP or TCP, no port scanning) to scan the specified IP address range and record the IP address/MAC address/Hostname responses in an XML file (nmap.xml).

I wrote a PowerShell script that munges the XML file and spits out a CSV file. This also filters out the down hosts. I find this easier to use in Excel than the XML file. Here's the script if anyone is interested.

# Define nmap input file
$NmapXMLFile = ".\nmap.xml"

# Initialize object array
$HostItems = @()

# Initialize index
$x = 0

# Load XML
[xml]$NmapXML = Get-Content $NmapXMLFile

# Loop through XML
ForEach ($HostNode in $NmapXML.nmaprun.host) {

  # Check host status
  If ($HostNode.status.state -eq "up") {

    # Create host object
    $HostObj = "" | Select-Object ID, Hostname, 'IP Address', 'MAC Address', Vendor

    # Store ID and increment index
    $HostObj.ID = $x += 1

    # Store hostname
    $HostObj.Hostname = $HostNode.hostnames.hostname.name

    # Loop through addresses
    foreach ($HostAddress in $HostNode.address) {

      # Check IP address
      If ($HostAddress.addrtype -eq "ipv4") {

        # Store IP address
        $HostObj.'IP Address' = $HostAddress.addr
      }

      # Check MAC address
      If ($HostAddress.addrtype -eq "mac") {

        # Store MAC address
        $HostObj.'MAC Address' = $HostAddress.addr

        # Store vendor
        $HostObj.Vendor = $HostAddress.vendor
      }
    }

    # Append host object to array
    $HostItems += $HostObj
  }
}

# Print host items
$HostItems

# Export host items to CSV
$HostItems | Export-CSV -NoType .\nmap.csv

Solution 4

From a Unix machine, listening to the no-OS computers on the same LAN, and if possible via a Hub (not a Switch), you can try

arp
cat /proc/net/arp

Also you may want to try wireshark (from a OS-ed machine). Again, better to use a Hub in order to catch any communications from the BIOS machines, including broadcasts.

Solution 5

  1. View info on your switch / router, if switch is advanced enough .
    (In Cisco switches command is show mac-address-table).
  2. If machines have PXE enabled BIOS / Networking card, read info from DHCP logs, as they will try to get DHCP lease. If you do not have DHCP, just dump all broadcast traffic with Wireshark and filter DHCP traffic. All newly powered machines without OS will show in traffic.
Share:
37,381

Related videos on Youtube

Admin
Author by

Admin

Updated on September 17, 2022

Comments

  • Admin
    Admin over 1 year

    How do I discover the MAC address of machines in a network?

    I need to discover the machines that are available just with only BIOS installed (no operating system).

    And I need to find the MAC address of machines that are up.

  • user1364702
    user1364702 over 13 years
    You might get it without a network stack if it's asking for bootp or pxe boot. Depends on the machine as to whether this would work though, I'd think.
  • imoatama
    imoatama over 13 years
    Edit - just reread the part about them being BIOS only. This presents further challenges beyond the problem of intercepting the layer 2 data - the clients may not even send any data over the network. If the clients have a bios that does DHCP, or sends ARP packets out, it should be possible to see them from the switch. I'm not sure what BIOS editions support this, I know some do though.
  • Stefan Lasiewski
    Stefan Lasiewski over 12 years
    I tried the command above, and got the error Scantype n not supported. Apparently the flag -sn is not supported on Nmap 4.x.
  • John Homer
    John Homer about 12 years
    From the nmap 5.30BETA1 ChangeLog:
  • John Homer
    John Homer about 12 years
    Switched to -Pn and -sn and as the preferred syntax for skipping ping scan and skipping port scan, respectively. Previously the -PN and -sP options were recommended. This establishes a more regular syntax for some options that disable phases of a scan: -n no reverse DNS -Pn no host discovery -sn no port scan We also felt that the old -sP ("ping scan") option was a bit misleading because current versions of Nmap can go much further (including -sC and --traceroute) even with port scans disabled. We will retain support for the previous option names for the foreseeable future.
  • John Homer
    John Homer about 12 years
    So based on that, you should be able to use the '-sP' syntax in place of the newer '-sn' parameter. Unfortunately, I don't have a version of nmap4 to test with.
  • kasperd
    kasperd almost 10 years
    I find it easier and more reliable to do such pings over IPv6 than over IPv4. An example command could look like this ping6 -c2 -n ff02::1%wlan0. One only need to update the name of the network interface to use, the IP address to use for that purpose is always ff02::1 regardless of which network you are on.