Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a command in powershell to get the IP information of a MAC

Tags:

powershell

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.

like image 987
user770022 Avatar asked Feb 03 '11 01:02

user770022


People also ask

How do I find the MAC address in PowerShell?

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.

Can you pull MAC address of an IP?

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.

How do I extract an IP address from a MAC 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.

How do you get IP address through PowerShell?

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.


2 Answers

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.

like image 122
Xavier Poinas Avatar answered Sep 29 '22 17:09

Xavier Poinas


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.

like image 26
Abhyudaya Sharma Avatar answered Sep 29 '22 18:09

Abhyudaya Sharma