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.
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.
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.
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.
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
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.
show mac-address-table
).A very easy little trick you could do within 2 seconds is working with the fact that any operating system writes a table with the mac and IP address of any device it interacts with. This is known as ARP TABLE. So the question is how to force an interaction with all devices? You could simply ping the broadcast IP address. This is not perfect, since some devices or firewall could block ICMP ping request, but it works in many scenarios.
The commands are (in a ipv4 192.168.0.255 broadcast address):
ping 192.168.0.255
In Linux use:
ping -b 192.168.0.255
Wait a few seconds for devices to respond, then do:
arp -a
For IPV6 ping see Giedrius Rekasius comment
Not perfect, but no tools, no research, no waste of time, works in every major operating system and is quick.
The basic problem here is that this is Layer 2 information, so only switches see it. Some switches will provide an interface that lets you peek at this info, but if they don't the only way to get it is to intercept in the physical layer, by eg installing a hub between the switch.
If you're using managed switches this information is likely available from the switch. Some end-user integrated routers/switches (such as the kind that often package ADSL modems as well) will sometimes have a DHCP client list which includes MAC addresses.
If you're using unmanaged switches, and you really want to know this info, I recommend you buy a hub, and temporarily replace the switch with it. You can then connect a computer running wireshark to the hub and capture ARP packets to record MAC addresses. Alternately you could use Echolot to do this for you - it selectively tracks ARP packets and builds a MAC address database.
Scan the network with Nmap and then check the ARP table (arp -a
in Linux distributions).
Here is a solution that worked for me:
As others have said, if you have unmanaged switches, or BootP/PXE, there's no easy way to get the MACs of machines with no OS.
If your running machines are running windows, it's easy to script (usually via WMI)
There are a bunch of examples here: http://gallery.technet.microsoft.com/ScriptCenter/en-us/site/search?f[0].Type=SearchText&f[0].Value=MAC+address&x=0&y=0
I was going to suggest switch MAC address table, but someone's already covered that one above.
If any of the computers are running an OS and have an IP addresses, you can connect into the same LAN, you could use NMAP (or a GUI version like Zenmap) from http://nmap.org/... if you run this on the same LAN, you should get MAC address info for any machines that respond.
It would be useful to understand more about why you need to get the MAC addresses, in case there is a better way of achieving the same result.
You can collect ARP information with for example a continuously running arpalert. With that, you will have the set of ARP addresses seen after start.
Powered off machines will not send you ARP replies.
To speed up the process, you can use an nmap ping scan (nmap -sP) on your network from the server you are running arpalert on, in order to trigger all possible (live and running) hosts to respond your arp query. With running nmap ping scan regularly later, you have better chances catching a shortly living host.
snippet from arpalert:
If the MAC is not in list, arpalert launches a pre-defined user script with the MAC address and IP address as parameters.
snippet from nmap:
Nmap ("Network Mapper") is a free and open source (license) utility for network exploration or security auditing
Look around here:
I use : nmap -sP 192.168.1.1/24
( replace 192.168.1.1/24 with your IP range )
It will show you only the machines that are up and will give you something like :
[root@x ~]# nmap -sP 192.168.1.1/24
Starting Nmap 6.40 ( http://nmap.org ) at 2014-11-22 14:20 EST
Nmap scan report for 192.168.1.1
Host is up (0.0019s latency).
MAC Address: ZZ:ZZ:54:2E:E9:B4 (Unknown)
Nmap scan report for 192.168.1.33
Host is up (0.035s latency).
MAC Address: ZZ:ZZ:FA:2D:D7:D8 (Intel Corporate)
Nmap scan report for 192.168.1.254
Host is up (0.0020s latency).
MAC Address: ZZ:ZZ:31:02:98:19 (Asustek Computer)
Nmap scan report for 192.168.1.34
Host is up.
Nmap done: 256 IP addresses (4 hosts up) scanned in 1.88 seconds
If you have no OS installed you can use a linux live cd, nmap is probably available in most of them