Trying to get network device names with reverse dns in Android
Asked Answered
D

2

6

I can able to fetch all device ip addresses in Local Area Network with inetaddress class. What I need to do is reverse lookup ip-address and find as device name in network like : "Jimmie's Macbook"

My Code block which able to fetch all IP address over Local Network Range:

        private ArrayList<String> scanSubNet(String subnet) {
            ArrayList<String> hosts = new ArrayList<>();
            InetAddress inetAddress;

            for (int i = 1; i <= 255; i++) {
                try {
                    inetAddress = InetAddress.getByName(subnet + String.valueOf(i));

                    if (inetAddress.isReachable(1000)) {
                        hosts.add(inetAddress.getHostName());
                        Log.d(TAG, InetAddress.getByAddress(inetAddress.getAddress()).getHostAddress());
                        Log.d(TAG, InetAddress.getByAddress(inetAddress.getAddress()).getCanonicalHostName());
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }

            return hosts;
        }

And i am calling my method as;

ArrayList<String> subnetList = scanSubNet("192.168.1.");ArrayList<String> subnetList = scanSubNet("192.168.1.");

in Log.d(TAG, i am trying to get device name with reverse dns. But both of line gives me output as ip-address ( Not Device-Name as string)

Is there any chance to succeed it ?

Regards, Onder.

Deerdre answered 21/9, 2016 at 8:43 Comment(0)
D
2

I just do it with fetching MACID and match first 3digits which belongs manufacturers.

https://macvendors.com/ this website also provide api (Post/GET) to resolve MAC Address.

Instead of resolve fullname of MAC, you need to do Handshake peer to peer.

Deerdre answered 30/9, 2016 at 9:6 Comment(0)
D
1

This is probably happening due to router misconfiguration.

Within a LAN, there are no crucial functions that depend on successful reverse DNS lookups, so a misconfiguration of that kind can easily go undetected for a long time.

It is kind of hard to tell what is wrong in your particular case without a lot more information about your LAN, but the first thing that comes to mind is configuring a proper "DNS Suffix" on the router. This is usually found under DHCP settings.

Drayman answered 29/9, 2016 at 20:54 Comment(1)
According to research, there is no way to get device name(s) from LocalNetwork DNS-reverse directly. You should have to make handshake with peer to peer devices such as share 1 file with Samba protocol.Deerdre

© 2022 - 2024 — McMap. All rights reserved.