6
3
I use ipconfig /all
or getmac /v
to get all NIC physical addresses.
But the problem is, generally a computer has more than one NIC card. Also there are some virtual MAC addresses—like Microsoft Virtual Wi-Fi hotspot NIC—which shows only when wifi hotspot is on.
So, how can I collect only the address corresponding to Ethernet via command prompt?
output: (using getmac /fo csv /v
and wifi hotspot OFF)
"Connection Name","Network Adapter","Physical Address","Transport Name"
"Ethernet","Realtek PCIe FE Family Controller","A0-2B-B8-27-62-12","\Device\Tcpi
p_{F1FF9AF6-AD1A-4C5E-8717-C646C9AE466C}"
"Wi-Fi","Qualcomm Atheros QCA9565 802.11b/g/n WiFi Adapter","28-E3-47-D2-FB-60",
"Media disconnected"
output: (using getmac /fo csv /v
and wifi hotspot ON)
"Connection Name","Network Adapter","Physical Address","Transport Name"
"Ethernet","Realtek PCIe FE Family Controller","A0-2B-B8-27-62-12","\Device\Tcpi
p_{F1FF9AF6-AD1A-4C5E-8717-C646C9AE466C}"
"Wi-Fi","Qualcomm Atheros QCA9565 802.11b/g/n WiFi Adapter","28-E3-47-D2-FB-60",
"Media disconnected"
"Local Area Connection* 7","Microsoft Hosted Network Virtual Adapter","4A-E3-47-
D2-FB-60","\Device\Tcpip_{630B2924-03A8-41C1-B1F2-D981A4C263C6}"
List of my all adapters: (wmic nic) http://pastebin.com/zyz9LjJe
UPDATE (possible solution): both @DavidPostill and @wmz 's answer helped me a lot. finally I got a solution to eliminate all virtual adapters with virtual MAC address.
x2-xx-xx-xx-xx-xx
x6-xx-xx-xx-xx-xx
xA-xx-xx-xx-xx-xx
xE-xx-xx-xx-xx-xx
MAC addresses with these ranges are used most by virtual MAC adapters. https://serverfault.com/questions/40712/what-range-of-mac-addresses-can-i-safely-use-for-my-virtual-machines
So, after getting all MAC addresses by getmac
command, we can filter out those virtual MAC addresses using regular expression. Moreover, we notice that filtering MAC by "wi-fi" is more reliable than filtering by "local area connection". So we filter out connections with "wi-fi" within their names to get final LAN/Ethernet conection.
Have you seen this answer which uses GNU
– JakeGould – 2015-03-22T23:38:57.813grep
for Windows?1What do you want to do if you have more than one NIC card? – DavidPostill – 2015-03-23T14:16:49.887
@DavidPostill, I need to get ONLY the LAN/Ethernet MAC address, irrespective of how the end user renamed the interface – Sourav Ghosh – 2015-03-24T13:05:09.083
Here is exact answer of your question. (Seems like this question is duplicate) – Just Shadow – 2018-02-15T14:55:55.150