I am wanting to have a simple command to resolve a MAC address to an IP. Is this even possible? I know the MAC address I am looking to get the IP address.
First, open Command Prompt, PowerShell, or Windows Terminal. Then, type in the command getmac and press Enter on your keyboard. The getmac command outputs a list of all your network adapters and their MAC addresses, which you can check in the Physical Address column highlighted below.
Ping the device you want to find a MAC address for using the local network address. Enter the ARP command with a "-a" flag. Look for the IP address in the results. The Mac address is next to the IP address.
To see all the MAC addresses and their associated IP addresses, type “arp -a”. This command will list all the available MAC addresses in the system. The address on the left is the IP address, while the right is the MAC address.
Use Get-NetIPAddress to Get IPv4 Address Into a Variable in PowerShell. The Get-NetIPAddress cmdlet gets the IP address configuration, such as IPv4 addresses, IPv6 addresses, and the IP interfaces associated with addresses.
This will give if the IP address if you already have the MAC/IP association in your ARP table:
arp -a | select-string "00-1c-87-c0-1c-5d" |% { $_.ToString().Trim().Split(" ")[0] }
returns
192.168.10.95
If you do not have the record in your ARP table, then I don't think that there is an easy way to do it.
One way would be to install arping and call it in a similar fashion from your Powershell script.
The Get-NetNeighbor
allows you to get the IP addresses from the MAC addresses if present in the ARP cache. For example:
Get-NetNeighbor -LinkLayerAddress ff-ff-ff-ff-ff-ff
will list all IP addresses with the MAC address equal to FF-FF-FF-FF-FF-FF
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With