LeGreen95
LeGreen95

Reputation: 101

Simple way to get MAC (Physical) address from inputted IP?

Is there any command similar to this code to print out the MAC address or "hash code" of the IP stored in this variable? I have done some research and it looks like it can be a really complex to impossible task. But I think it is worth a shot to ask. (Edit: Any IP I search is an internal IP to my Network).

            IPAddress addr = IPAddress.Parse(inputIP); //uses the input IP data into the addr variable to get host
            IPHostEntry entry = Dns.GetHostEntry(addr); //Get hostname
            Console.WriteLine("IP Address: " + addr);
            Console.WriteLine("Host Name: " + entry.HostName); //output logic

Upvotes: 0

Views: 1146

Answers (1)

take
take

Reputation: 2222

You can't get the MAC address of an ip which is not on your local network (i.e. the internet). For local IP/MAC addresses you can do an arp lookup.

This SO Post explains the arp lookup.

Upvotes: 1

Related Questions