Gettind a device MAC address by IP

get mac address from ip remotely
can you ping a mac address to get an ip
get mac address from ip linux
find device by mac address on network
how to identify a device by ip address
mac address to ip address converter
how to find ip addresses of devices on my network
can you get mac address from ip address

Well, in my app I use some code to discover all reachable devices in Local Network. Now I want to get device's mac address using local ip address

I want something like this: getMacAddress("192.168.1.23")

public static String getMacAddress(String ip)
{
    String macAddress = ...
    return macAddress;
}

I have found this but I am not sure if I can use it fro every device in LAN, if yes, how I will use it with custom ip address?

 WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
 WifiInfo info = manager.getConnectionInfo();
 String address = info.getMacAddress();

/proc/net/arp is the local ARP cache, which at least has cached entries (which may be offline).

protected String getMacAddress(String ipAddress) {
    try {
        BufferedReader br = new BufferedReader(new FileReader(new File("/proc/net/arp")));
        String line;
        while((line = br.readLine()) != null) {
            if(line.contains(ipAddress)) {
                /* this string still would need to be sanitized */
                return line;
            }
        }
        System.out.println(output);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

alternatively, one could scan the whole local network segment -

or retrieve the ARP cache from a local network router.

How to Find Any Device's IP Address, MAC Address, and Other , Type ipconfig /all at the command prompt to check the network card settings. Let’s say you have the MAC address 60-30-d4-76-b8-c8 (which is a macOS device) and you want to know the IP. From the results shown above, you can map the MAC address to the IP address in the same line. The IP Address is 192.168.0.102 (which is in the same network segment) belongs to 60-30-d4-76-b8-c8.

Ref: How can I get the number of devices connected through the phones access-point?

you can count connected devices on access point and it's get hardware mac address on below link on android: http://www.flattermann.net/2011/02/android-howto-find-the-hardware-mac-address-of-a-remote-host/

code from above link:

/**
 * Try to extract a hardware MAC address from a given IP address using the
 * ARP cache (/proc/net/arp).<br>
 * <br>
 * We assume that the file has this structure:<br>
 * <br>
 * IP address       HW type     Flags       HW address            Mask     Device
 * 192.168.18.11    0x1         0x2         00:04:20:06:55:1a     *        eth0
 * 192.168.18.36    0x1         0x2         00:22:43:ab:2a:5b     *        eth0
 *
 * @param ip
 * @return the MAC from the ARP cache
 */

public static String getMacFromArpCache(String ip) {
    if (ip == null)
        return null;
    BufferedReader br = null;
    try {
        br = new BufferedReader(new FileReader("/proc/net/arp"));
        String line;
        while ((line = br.readLine()) != null) {
            String[] splitted = line.split(" +");
            if (splitted != null && splitted.length >= 4 && ip.equals(splitted[0])) {
                // Basic sanity check
                String mac = splitted[3];
                if (mac.matches("..:..:..:..:..:..")) {
                    return mac;
                } else {
                    return null;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return null;
}

or if u have problem on code try below code:

 public ArrayList<InetAddress> getConnectedDevices(String YourPhoneIPAddress) {
        ArrayList<InetAddress> ret = new ArrayList<InetAddress>();

        LoopCurrentIP = 0;

        String IPAddress = "";
        String[] myIPArray = YourPhoneIPAddress.split("\\.");
        InetAddress currentPingAddr;


        for (int i = 0; i <= 255; i++) {
            try {

                // build the next IP address
                currentPingAddr = InetAddress.getByName(myIPArray[0] + "." +
                        myIPArray[1] + "." +
                        myIPArray[2] + "." +
                        Integer.toString(LoopCurrentIP));
                ad = currentPingAddr.toString();   /////////////////
                Log.d("MyApp",ad);                 //////////////

                // 50ms Timeout for the "ping"
                if (currentPingAddr.isReachable(50)) {

                    ret.add(currentPingAddr);
                    ad = currentPingAddr.toString();        /////////////////
                    Log.d("MyApp",ad);                     //////////////
                }
            } catch (UnknownHostException ex) {
            } catch (IOException ex) {
            }

            LoopCurrentIP++;
        }
        return ret;
    }

How to Find Your Device Mac Address, Or your computer is unable to display its IP due to various reasons, and you are getting a “No Valid IP Address” error. Finding the IP from a known  Well, in my app I use some code to discover all reachable devices in Local Network. Now I want to get device's mac address using local ip address I want something like this: getMacAddress("192.168

That function works only to get your own MAC, and even then it has severe limitations on modern Android. What you want isn't a feature of Android.

Can we know the name of the device through an IP address?, Here is one example of how to find a MAC address using an IP address. Start by pinging the device you want the MAC to address for: Use a local address, so if your network is 10.0.1.x, then use that number to ping. Use the following arp command to get a list that shows the MAC address of the device you pinged: It is usually not possible for a person to get the MAC address of a computer from its IP address alone. These two addresses originate from different sources. Simply stated, a computer's own hardware configuration determines its MAC address while the configuration of the network it is connected to determines its IP address.

Find Device or IP Address using Mac Address Free, Every network-connected device—computers, smartphones, tablets, smart home How to Find Any Device's IP Address, MAC Address, and Other Network You could also get there by clicking the menu button in Chrome,  You can also find out if the MAC address is from a switch or other networking device from HP, CISCO, etc. If you’re sure the MAC address is a computer, then try the methods below to determine the IP address. Method 1 – DHCP Server. The simplest way to get an IP address from a MAC address is to check out the DHCP server, if possible. Whether you are in a corporate environment or at home, each computer is being assigned an IP address from a DHCP server (unless it’s a static network

How to Find a MAC Address Using an IP Address, Using ARP, each computer maintains a list of both IP and MAC addresses for each device it has recently communicated with. Type "arp -a" in the command prompt. This lists a number of MAC addresses with the associated IP addresses. Since you have the MAC address, scroll down the list to find the associated IP address. The MAC address is shown in the "Physical Address" column with the IP address in the "Internet Address" column. An example of a table record is in Step 4.

How to get MAC address via IP, Hey everybody! Remember to comment, rate, and subscribe! I may do giveaways as the channel Duration: 2:19 Posted: Apr 10, 2016 Get mac address from command line (CMD) We can find mac address (physical address) of a computer using the command ‘getmac‘. This can be used to get mac address for remote computers also. Below are few examples on how to use this command. It works on XP, Vista, Windows 7, Server 2003 and Server 2008 operating systems.

Comments
  • There are many android apps that can do this, like fing or other play store apps. So how they do it?
  • WHat version of Android have you tested them on? As of 6.0, you can't even get your own MAC address- it returns a hardcoded 02:00:00:00:00:00